fluttercandies / extended_text_field

extended official text field to quickly build special text like inline image, @somebody, custom background etc.
MIT License
572 stars 148 forks source link

[Bug report] extende_text_field图文混合输入中,当输入框中只有图片时,添加换行符“\n”后,下一行行高会是“图片元素”的高度,输入一个字后,行高会缩小为“文字字号”高度,用户看到会行高闪烁问题 #240

Open ChanKen opened 2 months ago

ChanKen commented 2 months ago

Version

14.0.0

Platforms

iOS

Device Model

iphoneXR(iOS15.1)

flutter info

flutter doctor -v

[!] Flutter (Channel stable, 3.19.6, on macOS 13.5.2 22G91 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.19.6 on channel stable at /Users/liqian/.fvm/versions/3.13.2
    ! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/2.19.6/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/liqian/.fvm/versions/3.13.2. Consider adding /Users/liqian/.fvm/versions/3.13.2/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (3 months ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/liqian/Library/Android/sdk
    • Platform android-34, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.15.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

How to reproduce?

遇到一个extended-text-field 图文混排的行高问题,demo也有这情况。场景是:输入框中只有“图片元素”时,添加换行符“\n”后,下一行行高会是“图片元素”的高度,输入一个字后,行高会缩小为“文字字号”高度,用户看到会行高闪烁问题。

Logs

No response

Example code (optional)

Container(
              height: 200,
              child: ExtendedTextField(
                key: _key,
                // minLines: 1,
                maxLines: null,
                // expands: true,
                // maxLines: 2,
                // StrutStyle get strutStyle {
                //   if (_strutStyle == null) {
                //     return StrutStyle.fromTextStyle(style, forceStrutHeight: true);
                //   }
                //   return _strutStyle!.inheritFromTextStyle(style);
                // }
                //
                textInputAction: TextInputAction.newline,
                strutStyle: const StrutStyle(),
                specialTextSpanBuilder: MySpecialTextSpanBuilder(
                  showAtBackground: true,
                ),
                controller: _textEditingController,
                selectionControls: _myExtendedMaterialTextSelectionControls,
                extendedContextMenuBuilder: MyTextSelectionControls.defaultContextMenuBuilder,
                focusNode: _focusNode,
                decoration: InputDecoration(
                    suffixIcon: GestureDetector(
                      onTap: () {
                        setState(() {
                          sessions.insert(0, _textEditingController.text);
                          _textEditingController.value = _textEditingController.value.copyWith(text: '', selection: const TextSelection.collapsed(offset: 0), composing: TextRange.empty);
                        });
                      },
                      child: const Icon(Icons.send),
                    ),
                    contentPadding: const EdgeInsets.all(12.0)),
                //textDirection: TextDirection.rtl,
              ),
            ),

Contact

jin22dc@163.com

ChanKen commented 2 months ago

https://github.com/user-attachments/assets/68d8fee9-2c02-4280-a643-575c7d3107e8