Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在macos和web的时候,通过键盘左右箭头切换光标位置有问题 #216

Closed
1124863805 opened this issue Jun 26, 2023 · 1 comment

Comments

@1124863805
Copy link

Version

extended_text_field: ^11.0.1

Platforms

macOS, Web, Windows

Device Model

macos

flutter info

• Flutter version 3.7.3 on channel stable at /Users/liyao/fvm/versions/3.7.3
    ! Warning: `dart` on your path resolves to
      /usr/local/Cellar/dart/2.12.1/libexec/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/liyao/fvm/versions/3.7.3. Consider
      adding /Users/liyao/fvm/versions/3.7.3/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9944297138 (5 months ago), 2023-02-08 15:46:04 -0800
    • Engine revision 248290d6d5
    • Dart version 2.19.2
    • DevTools version 2.20.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.

How to reproduce?

1 .通过左右箭头进行切换光标,无法一个一个进行移动,发现移动几个之后就会回退
2.在最后一个字符,之前删除无法完全删除 ,会留下一个最后一个字符 ],其他删除正常

425_1687765409.mp4

Logs

No response

Example code (optional)

ExtendedTextField(
  style: TextStyle(fontSize: 18),                                                           specialTextSpanBuilder:MySpecialTextSpanBuilder(),
   scrollController: controller.scrollController,
                                                                autofocus: true,
                                                                scrollPadding: EdgeInsets.all(50),
                                                                controller: controller.chatTextFieldController,
                                                                focusNode: controller.focusNode,
                                                                keyboardType: TextInputType.multiline,
                                                                maxLines: 100,
                                                                decoration: const InputDecoration(
                                                                    border: InputBorder.none,
                                                                    isDense: true,
                                                                    contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 18)),
                                                              )


Map<String, String> EMOJI_CONSTANT = {
  "[龇牙]":
  "https://imgcache.qq.com/open/qcloud/tim/assets/emoji/emoji_141@2x.png",
  "[调皮]":
  "https://imgcache.qq.com/open/qcloud/tim/assets/emoji/emoji_113@2x.png"
};

import 'package:extended_text_field/extended_text_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_chat/app/constant/emoji_constant.dart';

class EmojiText extends SpecialText {

  EmojiText(TextStyle? textStyle, {this.start})
      : super(EmojiText.flag, ']', textStyle);
  static const String flag = '[';
  final int? start;
  @override
  InlineSpan finishText() {
    final String key = toString();

    if (EMOJI_CONSTANT.containsKey(key)) {
      double size = 18;


      return ImageSpan(
          NetworkImage(EMOJI_CONSTANT[key]!,),
          actualText: key,
          imageWidth: size,
          imageHeight: size,
          start: start!,
          fit: BoxFit.fill,
          );
    }

    return TextSpan(text: toString(), style: textStyle);
  }

}


class MySpecialTextSpanBuilder extends SpecialTextSpanBuilder {
  MySpecialTextSpanBuilder({this.showAtBackground = false});

  /// whether show background for @somebody
  final bool showAtBackground;

  @override
  SpecialText? createSpecialText(String flag,
      {TextStyle? textStyle,
        SpecialTextGestureTapCallback? onTap,
        int? index}) {
    if (flag == '') {
      return null;
    }if (isStart(flag, EmojiText.flag)) {
      return EmojiText(textStyle, start: index! - (EmojiText.flag.length - 1));
    }
    return null;
  }
}

Contact

No response

@zmtzawqlp
Copy link
Member

#210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants