A powerful extended official text for Flutter, which supports Speical Text(Image,@somebody), Custom Background, Custom overFlow, Text Selection.

Overview

extended_text

pub package GitHub stars GitHub forks GitHub license GitHub issues flutter-candies

Language: English | 中文简体

Extended official text to build special text like inline image or @somebody quickly,it also support custom background,custom over flow and custom selection toolbar and handles.

Table of contents

Speical Text

Create Speical Text

extended text helps to convert your text to speical textSpan quickly.

for example, follwing code show how to create @xxxx speical textSpan.

class AtText extends SpecialText {
  AtText(TextStyle textStyle, SpecialTextGestureTapCallback onTap,
      {this.showAtBackground = false, this.start})
      : super(flag, ' ', textStyle, onTap: onTap);
  static const String flag = '@';
  final int start;

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

  @override
  InlineSpan finishText() {
    final TextStyle textStyle =
        this.textStyle?.copyWith(color: Colors.blue, fontSize: 16.0);

    final String atText = toString();

    return showAtBackground
        ? BackgroundTextSpan(
            background: Paint()..color = Colors.blue.withOpacity(0.15),
            text: atText,
            actualText: atText,
            start: start,

            ///caret can move into special text
            deleteAll: true,
            style: textStyle,
            recognizer: (TapGestureRecognizer()
              ..onTap = () {
                if (onTap != null) {
                  onTap(atText);
                }
              }))
        : SpecialTextSpan(
            text: atText,
            actualText: atText,
            start: start,
            style: textStyle,
            recognizer: (TapGestureRecognizer()
              ..onTap = () {
                if (onTap != null) {
                  onTap(atText);
                }
              }));
  }
}

SpecialTextSpanBuilder

create your SpecialTextSpanBuilder

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

  /// whether show background for @somebody
  final bool showAtBackground;
  @override
  TextSpan build(String data,
      {TextStyle textStyle, SpecialTextGestureTapCallback onTap}) {
    if (kIsWeb) {
      return TextSpan(text: data, style: textStyle);
    }

    return super.build(data, textStyle: textStyle, onTap: onTap);
  }

  @override
  SpecialText createSpecialText(String flag,
      {TextStyle textStyle, SpecialTextGestureTapCallback onTap, int index}) {
    if (flag == null || flag == '') {
      return null;
    }

    ///index is end index of start flag, so text start index should be index-(flag.length-1)
    if (isStart(flag, AtText.flag)) {
      return AtText(
        textStyle,
        onTap,
        start: index - (AtText.flag.length - 1),
        showAtBackground: showAtBackground,
      );
    } else if (isStart(flag, EmojiText.flag)) {
      return EmojiText(textStyle, start: index - (EmojiText.flag.length - 1));
    } else if (isStart(flag, DollarText.flag)) {
      return DollarText(textStyle, onTap,
          start: index - (DollarText.flag.length - 1));
    }
    return null;
  }
}

Image

ImageSpan

show inline image by using ImageSpan.

class ImageSpan extends ExtendedWidgetSpan {
  ImageSpan(
    ImageProvider image, {
    Key key,
    @required double imageWidth,
    @required double imageHeight,
    EdgeInsets margin,
    int start = 0,
    ui.PlaceholderAlignment alignment = ui.PlaceholderAlignment.bottom,
    String actualText,
    TextBaseline baseline,
    BoxFit fit= BoxFit.scaleDown,
    ImageLoadingBuilder loadingBuilder,
    ImageFrameBuilder frameBuilder,
    String semanticLabel,
    bool excludeFromSemantics = false,
    Color color,
    BlendMode colorBlendMode,
    AlignmentGeometry imageAlignment = Alignment.center,
    ImageRepeat repeat = ImageRepeat.noRepeat,
    Rect centerSlice,
    bool matchTextDirection = false,
    bool gaplessPlayback = false,
    FilterQuality filterQuality = FilterQuality.low,
    GestureTapCallback onTap,
    HitTestBehavior behavior = HitTestBehavior.deferToChild,
  })
parameter description default
image The image to display(ImageProvider). -
imageWidth The width of image(not include margin) required
imageHeight The height of image(not include margin) required
margin The margin of image -
actualText Actual text, take care of it when enable selection,something likes "[love]" '\uFFFC'
start Start index of text,take care of it when enable selection. 0

Selection

parameter description default
selectionEnabled Whether enable selection false
selectionColor Color of selection Theme.of(context).textSelectionColor
dragStartBehavior DragStartBehavior for text selection DragStartBehavior.start
textSelectionControls An interface for building the selection UI, to be provided by the implementor of the toolbar widget or handle widget extendedMaterialTextSelectionControls/extendedCupertinoTextSelectionControls

TextSelectionControls

default value of textSelectionControls are MaterialExtendedTextSelectionControls/CupertinoExtendedTextSelectionControls

override buildToolbar or buildHandle to custom your toolbar widget or handle widget

class MyExtendedMaterialTextSelectionControls
    extends ExtendedMaterialTextSelectionControls {
  MyExtendedMaterialTextSelectionControls();
  @override
  Widget buildToolbar(
    BuildContext context,
    Rect globalEditableRegion,
    double textLineHeight,
    Offset selectionMidpoint,
    List<TextSelectionPoint> endpoints,
    TextSelectionDelegate delegate,
  ) {}

  @override
  Widget buildHandle(
      BuildContext context, TextSelectionHandleType type, double textHeight) {
  }
}

Control ToolBar Handle

contain your page into ExtendedTextSelectionPointerHandler, so you can control toolbar and handle.

Default Behavior

set your page as child of ExtendedTextSelectionPointerHandler

 return ExtendedTextSelectionPointerHandler(
      //default behavior
       child: result,
    );
  • tap region outside of extended text, hide toolbar and handle
  • scorll, hide toolbar and handle

Custom Behavior

get selectionStates(ExtendedTextSelectionState) by builder call back, and handle by your self.

 return ExtendedTextSelectionPointerHandler(
      //default behavior
      // child: result,
      //custom your behavior
      builder: (states) {
        return Listener(
          child: result,
          behavior: HitTestBehavior.translucent,
          onPointerDown: (value) {
            for (var state in states) {
              if (!state.containsPosition(value.position)) {
                //clear other selection
                state.clearSelection();
              }
            }
          },
          onPointerMove: (value) {
            //clear other selection
            for (var state in states) {
              state.clearSelection();
            }
          },
        );
      },
    );

Custom Background

refer to issues 24335/24337 about background

  BackgroundTextSpan(
      text:
          "This text has nice background with borderradius,no mattter how many line,it likes nice",
      background: Paint()..color = Colors.indigo,
      clipBorderRadius: BorderRadius.all(Radius.circular(3.0))),
parameter description default
background Background painter -
clipBorderRadius Clip BorderRadius -
paintBackground Paint background call back, you can paint background by self -

Custom Overflow

refer to issue 26748

parameter description default
child The widget of TextOverflow. @required
maxHeight The maxHeight of [TextOverflowWidget], default is preferredLineHeight. preferredLineHeight
align The Align of [TextOverflowWidget], left/right. right
position The position which TextOverflowWidget should be shown. TextOverflowPosition.end
  ExtendedText(
   overflowWidget: TextOverflowWidget(
     position: TextOverflowPosition.end,
     align: TextOverflowAlign.center,
     // just for debug
     debugOverflowRectColor: Colors.red.withOpacity(0.1),
     child: Container(
       child: Row(
         mainAxisSize: MainAxisSize.min,
         children: <Widget>[
           const Text('\u2026 '),
           InkWell(
             child: const Text(
               'more',
             ),
             onTap: () {
               launch(
                   'https://github.com/fluttercandies/extended_text');
             },
           )
         ],
       ),
     ),
   ),
  )

Join Zero-Width Space

refer to issue 18761

if [ExtendedText.joinZeroWidthSpace] is true, it will join '\u{200B}' into text, make line breaking and overflow style better.

  ExtendedText(
      joinZeroWidthSpace: true,
    )

or you can convert by following method:

  1. String
  String input='abc'.joinChar();
  1. InlineSpan
     InlineSpan innerTextSpan;
     innerTextSpan = joinChar(
        innerTextSpan,
        Accumulator(),
        zeroWidthSpace,
    );

Take care of following things:

  1. the word is not a word, it will not working when you want to double tap to select a word.

  2. text is changed, if [ExtendedText.selectionEnabled] is true, you should override TextSelectionControls and remove zeroWidthSpace.

class MyTextSelectionControls extends TextSelectionControls {

  @override
  void handleCopy(TextSelectionDelegate delegate,
      ClipboardStatusNotifier? clipboardStatus) {
    final TextEditingValue value = delegate.textEditingValue;

    String data = value.selection.textInside(value.text);
    // remove zeroWidthSpace
    data = data.replaceAll(zeroWidthSpace, '');

    Clipboard.setData(ClipboardData(
      text: value.selection.textInside(value.text),
    ));
    clipboardStatus?.update();
    delegate.textEditingValue = TextEditingValue(
      text: value.text,
      selection: TextSelection.collapsed(offset: value.selection.end),
    );
    delegate.bringIntoView(delegate.textEditingValue.selection.extent);
    delegate.hideToolbar();
  }
}
Comments
  • 如果text的文本是带回车换行的字符串,大概率会出现报错

    如果text的文本是带回车换行的字符串,大概率会出现报错

    如果后台放回的content的格式是如下这种 image

    ExtendedText(
                          content,
                          maxLines: 3,
                          style: TvStyle.tv_size_28_color_333333,
                          overFlowTextSpan: OverFlowTextSpan(
                            children: <TextSpan>[
                              TextSpan(text: '  \u2026  '),
                              TextSpan(
                                text: "全文",
                                style: TvStyle.tv_size_28_color_5765AD,
                              )
                            ],
                            background: Theme.of(context).canvasColor,
                          ),
                        ),
    

    报错信息:

    image

    opened by cixiu 11
  • can't reponse tap gesture

    can't reponse tap gesture

    @override
      Widget build(BuildContext context) {
        return Container(
          margin: EdgeInsets.all(10),
          padding: EdgeInsets.all(10),
          color: Colors.white,
          child: StreamBuilder<bool>(
            stream: _cellBloc.isSpread,
            initialData: false,
            builder: (context, snapshot) {
              return snapshot.data ? buildSpreadCell() : buildFoldCell();
            },
          ),
        );
      }
    
      Widget buildFoldCell() {
        return ExtendedText(
          's我觉得搜jog就搜集公司偶的机构就搜到结构将搜集的工具OS 是的解耦就搜集滚动事件酸豆角构建搜的感觉是家大公鸡搜到过建瓯市就酸豆角构建搜见到过',
          style: TextStyle(fontSize: 16),
          maxLines: 2,
          overFlowTextSpan: OverFlowTextSpan(
            children: [
              TextSpan(
                  text: "\u2026 展开",
                  style: TextStyle(color: Color(0xff9c9c9c), fontSize: 14),
                  recognizer: TapGestureRecognizer()
                    ..onTap = () {
                      debugPrint('点击');
                      _mainBloc.addToFolds(widget.data);
                    })
            ],
            background: Colors.white,
          ),
        );
      }
     ....
    

    when i tap the textspan, the console log

    flutter: Another exception was thrown: NoSuchMethodError: The getter 'dx' was called on null.
    
    bug 
    opened by OHeroJ 11
  • 当TextOverflowWidget和emoji同时使用时报错

    当TextOverflowWidget和emoji同时使用时报错

    ════════ Exception caught by painting library ══════════════════════════════════
    Invalid argument(s): string is not well-formed UTF-16
    ════════════════════════════════════════════════════════════════════════════════
    
    import 'package:extended_text/extended_text.dart';
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return const MaterialApp(
          home: HomePage(),
        );
      }
    }
    
    class HomePage extends StatefulWidget {
      const HomePage({Key? key}) : super(key: key);
    
      @override
      _HomePageState createState() => _HomePageState();
    }
    
    class _HomePageState extends State<HomePage> {
      _HomePageState();
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            body: Container(
              color: Colors.red,
              constraints: BoxConstraints(maxWidth: 240),
              child: ExtendedText(
                '呆呆很长呆呆很长rrr🌧rw..呆呆很长呆呆rrrrrrr',
                joinZeroWidthSpace: true,
                maxLines: 1,
                style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500),
                overflowWidget: TextOverflowWidget(
                  position: TextOverflowPosition.middle,
                  align: TextOverflowAlign.center,
                  child: Text(
                    '...',
                  ),
                ),
              ),
            ),
          ),
        );
      }
    }
    
    opened by ma125125t 10
  • Chrome Breaking for Mixin: TextEditingActionTarget

    Chrome Breaking for Mixin: TextEditingActionTarget

    Hello, there is a breakage with the TextEditingAction target. Here is the error I am getting:

    Running "flutter pub get" in hatch_success_flutter...
    Launching lib/main.dart on Chrome in debug mode...
    Waiting for connection from debug service on Chrome...
    ../../../../../.pub-cache/hosted/pub.dartlang.org/extended_text-8.0.2/lib/src/selection/extended_text_selection.dart:136:10: Error: Type 'TextEditingActionTarget' not found.
        with TextEditingActionTarget
             ^^^^^^^^^^^^^^^^^^^^^^^
    ../../../../../.pub-cache/hosted/pub.dartlang.org/extended_text-8.0.2/lib/src/selection/extended_text_selection.dart:135:7: Error: The type 'TextEditingActionTarget' can't be mixed in.
    class ExtendedTextSelectionState extends State<ExtendedTextSelection>
          ^
    Failed to compile application.
    
    

    Not sure how to fix this. This is when I tried to compile for web. Any pointers would be great!

    SDK build error 
    opened by ngocatfika 9
  • Throwable: 'package:extended_text/src/extended_render_paragraph.dart': Failed assertion: line 810 pos 9: 'textPainter.width <= rect.width': is not true.

    Throwable: 'package:extended_text/src/extended_render_paragraph.dart': Failed assertion: line 810 pos 9: 'textPainter.width <= rect.width': is not true.

    使用的版本:0.6.6

    复现步骤:

    换
    换
    换
    
    

    使用部件显示上面的文本,然后限制3行,

    ExtendedText(
                  ““”换
    换
    换
    ”““,
                  style: AppTextStyles.feedContentStyle,
                  maxLines: 3,
                  overflow: TextOverflow.ellipsis,
                  overFlowTextSpan:
                      OverFlowTextSpan( children: [
                    TextSpan(
                        text: '\u2026',
                        children: [
                          TextSpan(
                              text: '全文',
                              style: AppTextStyles.feedContentStyle
                                  .copyWith(color: Colors.blue))
                        ],
                        style: AppTextStyles.feedContentStyle.copyWith(
                          fontSize: getSp(28)
                        )),
                  ]),
                )
    
    opened by rhymelph 8
  • Long press on iOS for Extended Text Selection

    Long press on iOS for Extended Text Selection

    Hi - is there a way to implement long press for the Selection Menu on iOS? Currently I have long press on Android but need to double click for iOS which users are not discovering.
    Thanks for the great plugin by the way!

    opened by hovermouse 6
  • 使用flutter2时编译报错

    使用flutter2时编译报错

    报错如下

    G:\Projects\flutter\naturec_flutter>flutter run
    Launching lib\main.dart on VIE AL10 in debug mode...
    /D:/ProgramData/flutter/.pub-cache/hosted/pub.flutter-io.cn/extended_text-5.0.5/lib/src/selection/extended_text_selection.dart:131:7: Error: The non-abstract class 'ExtendedTextSelectionState' is missing implementations for these members:
     - TextSelectionDelegate.userUpdateTextEditingValue
    Try to either
     - provide an implementation,
     - inherit an implementation from a superclass or mixin,
     - mark the class as abstract, or
     - provide a 'noSuchMethod' implementation.
    
    class ExtendedTextSelectionState extends State<ExtendedTextSelection>   
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
    /D:/ProgramData/flutter/packages/flutter/lib/src/services/text_input.dart:822:8: Context: 'TextSelectionDelegate.userUpdateTextEditingValue' is defined here.
      void userUpdateTextEditingValue(TextEditingValue value, SelectionChangedCause cause);
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
    /D:/ProgramData/flutter/.pub-cache/hosted/pub.flutter-io.cn/extended_text-5.0.5/lib/src/selection/extended_text_selection.dart:434:8: Error: The method 'ExtendedTextSelectionState.hideToolbar' has fewer positional arguments than those of overridden method 'TextSelectionDelegate.hideToolbar'.
      void hideToolbar() {
           ^
    /D:/ProgramData/flutter/packages/flutter/lib/src/services/text_input.dart:829:8: Context: This is the overridden method ('hideToolbar').
      void hideToolbar([bool hideHandles = true]);
           ^
                                                                            
                                                                            
    FAILURE: Build failed with an exception.
    
    * Where:
    Script 'D:\ProgramData\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1029
    
    * What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.
    > Process 'command 'D:\ProgramData\flutter\bin\flutter.bat'' finished with non-zero exit value 1
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 18s
    Running Gradle task 'assembleDebug'...
    Running Gradle task 'assembleDebug'... Done                        19.0s
    Exception: Gradle task assembleDebug failed with exit code 1
    

    使用的包是extended_text: ^5.0.5,看这个报错,没太懂是我需要实现这个类,还是包本身缺少了这个类的实现。主要是编辑器环境也没报错

    opened by mojerro 5
  • Layout bug with ExtendedText overflowWidget

    Layout bug with ExtendedText overflowWidget

    Example code to reproduce the bug

    import 'package:extended_text/extended_text.dart';
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(App());
    }
    
    class App extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: ExtendedTextLayoutBug(),
        );
      }
    }
    
    class ExtendedTextLayoutBug extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: ExtendedText(
              'ABCDEFG',
              overflow: TextOverflow.ellipsis,
              maxLines: 3,
              overflowWidget: TextOverflowWidget(
                child: Text(' ...more'),
              ),
            ),
          ),
        );
      }
    }
    

    Error log

    
    ════════ Exception caught by scheduler library ═════════════════════════════════
    The following assertion was thrown during a scheduler callback:
    Updated layout information required for RenderSemanticsAnnotations#b31d0 NEEDS-LAYOUT NEEDS-PAINT to calculate semantics.
    'package:flutter/src/rendering/object.dart':
    Failed assertion: line 2658 pos 12: '!_needsLayout'
    
    2
    
    Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
    In either case, please report this assertion by filing a bug on GitHub:
      https://github.com/flutter/flutter/issues/new?template=2_bug.md
    
    When the exception was thrown, this was the stack
    #2      RenderObject._getSemanticsForParent
    package:flutter/…/rendering/object.dart:2658
    #3      RenderObject._getSemanticsForParent.<anonymous closure>
    package:flutter/…/rendering/object.dart:2680
    #4      ContainerRenderObjectMixin.visitChildren
    package:flutter/…/rendering/object.dart:3336
    #5      RenderObject.visitChildrenForSemantics
    package:flutter/…/rendering/object.dart:2765
    #6      RenderObject._getSemanticsForParent
    package:flutter/…/rendering/object.dart:2675
    ...
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by Flutter framework ═════════════════════════════════
    Bad state: Future already completed
    ════════════════════════════════════════════════════════════════════════════════
    
    bug 
    opened by VictorUvarov 5
  • this widget makes gestureDetector don't work

    this widget makes gestureDetector don't work

    1. this widget makes gestureDetector don't work. Like when I want to longPress on a selectable text by gestureDetector, it won't work.

    Looking forward to you reply. Thanks in advance.

    opened by FitzMusk 4
  • type 'List<InlineSpan?>' is not a subtype of type 'List<InlineSpan>?' in type cast

    type 'List' is not a subtype of type 'List?' in type cast

    Using flutter with sound null-safe is throwing this error:

    ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
    The following _CastError was thrown building ExtendedText-[GlobalKey#cba4d](null,
      ╞═╦══ textSpan ═══
        ║ TextSpan:
        ║   "Ola mundo!"
      , debugLabel: (((blackMountainView bodyText1).apply).copyWith).copyWith, inherit: true, color:
    Color(0xff333333), family: Merriweather, size: 20.0, height: 1.5x, decoration: TextDecoration.none,
    textHeightBehavior: TextHeightBehavior(applyHeightToFirstAscent: true, applyHeightToLastDescent:
    true), dirty, dependencies: [DefaultTextStyle, MediaQuery]):
    type 'List<InlineSpan?>' is not a subtype of type 'List<InlineSpan>?' in type cast
    
    The relevant error-causing widget was:
      ExtendedText-[GlobalKey#cba4d]
      file:///home/peleteiro/Projects/biblebox/app/lib/widget/fragment_widget/fragment_widget.dart:128:27
    
    When the exception was thrown, this was the stack:
    #0      ExtendedText.build (package:extended_text/src/extended_text.dart:224:11)
    

    The code is at: https://github.com/fluttercandies/extended_text/blob/575489c9aed1698d11f1ed398e3c4cb3d45d2ca9/lib/src/extended_text.dart#L223

    It looks like it should be:

          children: (textSpan != null ? <InlineSpan>[textSpan] : null)
              as List<InlineSpan>?,
    
    opened by peleteiro 3
  • Click outside of extended text raises exception

    Click outside of extended text raises exception

    The following assertion was thrown while handling a gesture: Looking up a deactivated widget's ancestor is unsafe.

    At this point the state of the widget's element tree is no longer stable.

    To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.

    When the exception was thrown, this was the stack: #0 Element._debugCheckStateIsActiveForAncestorLookup. (package:flutter/src/widgets/framework.dart:3508:9) #1 Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/framework.dart:3522:6) #2 Element.findAncestorStateOfType (package:flutter/src/widgets/framework.dart:3641:12) #3 Overlay.of (package:flutter/src/widgets/overlay.dart:237:41) #4 ExtendedTextSelectionOverlay.showToolbar (package:extended_text_library/src/selection/extended_text_selection_overlay.dart:193:13) ... Handler: "onTap" Recognizer: TapGestureRecognizer#af7cb debugOwner: GestureDetector state: ready won arena finalPosition: Offset(38.8, 23.6) button: 1 sent tap down

    opened by a-v-ebrahimi 3
  • ExtendedText  style 设置字体大小后 overflowWidget 不显示

    ExtendedText style 设置字体大小后 overflowWidget 不显示

    ExtendedText( "Coupons can be used only if this condition is me", maxLines: 2, style: Theme.of(context).textTheme.caption?.copyWith( fontSize: 35.w ), overflow: TextOverflow.ellipsis, overflowWidget: TextOverflowWidget( position: TextOverflowPosition.end, align: TextOverflowAlign.center, // just for debug // debugOverflowRectColor: Colors.red.withOpacity(0.1), child: Container( child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Text('\u2026 ', style: Theme.of(context).textTheme.caption?.copyWith( // fontSize: 35.w ),), InkWell( child: const Text( 'more', style: TextStyle( color: Colors.red ), ), onTap: () { // launch( // 'https://github.com/fluttercandies/extended_text'); }, ) ], ), ), ), )

    flutter : 2.5.0 extended_text : 7.0.0

    opened by zhanglijie5997 1
  • ExtendedText文本渲染错位

    ExtendedText文本渲染错位

    下图激活selection,可以看到,选中的位置和文本真实位置有一点错位,随着文本行数不断增加,这种错位逐渐累计,变得越来越明显。

    Screenshot_2021-09-13-01-53-35-028_com example ex

    该问题的复现方法:

    import 'package:extended_text/extended_text.dart';
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: MyHomePage(),
        );
      }
    }
    
    class MyHomePage extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text("测试"),),
          body: ListView(
            children: [
              ExtendedText(
                "测试测试测试 ----\n   1123\n"*100,
                selectionEnabled: true,
                style: TextStyle(fontSize: 14),
              )
            ],
          ),
        );
      }
    }
    
    

    版本:Flutter 2.2.3 平台:Android(Windows似乎没有这个问题)

    此外,ExtendedTextField也没有这个问题

    opened by blueloveTH 10
  • TextOverflowWidget的align:TextOverflowAlign.left属性没有效果

    TextOverflowWidget的align:TextOverflowAlign.left属性没有效果

    如题:期望能显示在最后的文字旁边,即333的旁边 left class BackgroundTextDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('nick background for text'), ), body: SingleChildScrollView( child: Container( color: Colors.green, width: 400, padding: const EdgeInsets.all(20.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ ExtendedText.rich( TextSpan( text: '11111111111111111111111111111111\n', ), TextSpan( text: '222222212222222222222222222222222222222\n', ), TextSpan( text: '3333\n', ), TextSpan( text: '444444\n', ), ]), maxLines: 3, overflow: TextOverflow.visible, overflowWidget: TextOverflowWidget( align:TextOverflowAlign.left, position: TextOverflowPosition.end, debugOverflowRectColor: Colors.red.withOpacity(0.1), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment:MainAxisAlignment.end, children: const [ Text( '...', ), Text( '全文', style: TextStyle( height: 1, fontSize: 16, color: Colors.amber), ), ], ), ), ), ], )), ), ); } }

    enhancement 
    opened by miduobao 5
Owner
FlutterCandies
Custom Flutter candies (packages) for you to build your Flutter app easily. Enjoy it!
FlutterCandies
A Flutter package to parse text and make them into linkified text widget

?? Flutter Parsed text A Flutter package to parse text and extract parts using predefined types like url, phone and email and also supports Regex. Usa

Fayeed Pawaskar 213 Dec 27, 2022
Rich Text renderer that parses Contentful Rich Text JSON object and returns a renderable Flutter widget

Contentful Rich Text Renderer for Flutter Rich Text renderer that parses Contentful Rich Text field JSON output and produces a Flutter Widget tree tha

Kumanu 45 Nov 10, 2022
A masked text for Flutter.

flutter_masked_text Masked text input for flutter. Alert Hi guys! Unfortunately, I'm not developing mobile anymore. This repo will not receive updates

Ben-hur Santos Ott 264 Dec 21, 2022
Soft and gentle rich text editing for Flutter applications.

About Zefyr Soft and gentle rich text editing for Flutter applications. You are viewing early dev preview version of this package which is no longer a

Memspace 2.2k Jan 8, 2023
Flutter widget that automatically resizes text to fit perfectly within its bounds.

Flutter widget that automatically resizes text to fit perfectly within its bounds. Show some ❤️ and star the repo to support the project Resources: Do

Simon Leier 1.8k Jan 3, 2023
A simple Flutter package that makes turning a FAB into a text field easy.

flutter_text_field_fab A simple Flutter widget that makes turning a FAB into a text field easy.

Haefele Software 4 Jan 18, 2022
Soft and gentle rich text editing for Flutter applications

Soft and gentle rich text editing for Flutter applications. Zefyrka is a fork of Zefyr package with the following improvements: support Flutter 2.0 op

null 85 Dec 21, 2022
Arc Text Widget for Flutter

Flutter Arc Text Renders text along the arc. See demo. The story behind the plugin is here. Basic usage class MyApp extends StatelessWidget

Kirill Bubochkin 15 Oct 18, 2021
Text Editor in Flutter for Android and iOS to help free write WYSIWYG HTML code

Flutter Summernote Text Editor in Flutter for Android and iOS to help free write WYSIWYG HTML code based on Summernote 0.8.18 javascript wrapper. NOTI

Chandra Abdul Fattah 41 Sep 12, 2022
A customizable code text field supporting syntax highlighting

CodeField A customizable code text field supporting syntax highlighting Live demo A live demo showcasing a few language / themes combinaisons Showcase

Bertrand 162 Dec 23, 2022
Flutter textfield validation lets you validate different textform fields in your Flutter app

Flutter textfield validation lets you validate different textform fields in your Flutter app

World-Package 2 Sep 15, 2022
A markdown renderer for Flutter.

Flutter Markdown A markdown renderer for Flutter. It supports the original format, but no inline HTML. Overview The flutter_markdown package renders M

Flutter 828 Aug 12, 2021
A Flutter Package to render Mathematics, Physics and Chemistry Equations based on LaTeX

flutter_tex Contents About Demo Video Screenshots How to use? Android iOS Web Examples Quick Example TeXView Document TeXView Markdown TeXView Quiz Te

Shahzad Akram 219 Jan 5, 2023
flutter 中文排版,支持分页上下对齐 两端对齐 翻页动画

text_composition flutter 中文排版 分页 上下对齐 两端对齐 多栏布局 弃用richText,使用Canvas,精确定位绘图位置,消除字体对排版影响 视频与截图 demo https://github.com/mabDc/text_composition/releases/t

西红柿大芝麻 50 Nov 3, 2022
Flutter Tutorial - PDF Viewer - Asset, File, Network & Firebase

Flutter Tutorial - PDF Viewer - Asset, File, Network & Firebase Use the Flutter PDF Viewer to download PDF documents and display them within your Flut

Johannes Milke 36 Dec 9, 2022
Create an AutoComplete TextField to search JSON data based on suggestions in Flutter.

Flutter Tutorial - AutoComplete TextField & AutoComplete Search Create an AutoComplete TextField to search JSON data based on suggestions in Flutter.

Johannes Milke 32 Oct 23, 2022
Flutter phone number input

phone_form_field Flutter phone input integrated with flutter internationalization Features Totally cross platform, this is a dart only package / depen

cedvdb 38 Dec 31, 2022
A low code editor with the full power of flutter.

flutter_blossom ?? Low code editor with the full power of flutter. Think in flutter, watch your ideas come to life, plan ahead and let your creativity

Flutter Blossom 0 Dec 2, 2021
A Flutter package provides some implementations of TextInputFormatter that format input with pre-defined patterns

A Flutter package provides some implementations of TextInputFormatter that format input with pre-defined patterns

HungHD 192 Dec 31, 2022