2000calories / flutter_easy_rich_text

The EasyRichText widget provides an easy way to use RichText.
https://pub.dev/packages/easy_rich_text
MIT License
79 stars 34 forks source link

An icon next to the match #42

Closed zthrive closed 1 year ago

zthrive commented 1 year ago

Is it possible to add a little icon next to the matched pattern - e.g. if phone number is detected a little icon of the phone is displayed

2000calories commented 1 year ago

Currently not supported by EasyRichText. RichText widget support WidgetSpan in which you can add icon.

zthrive commented 1 year ago

Thank you for responding. If I use suggested code then there is the icon but there is no clickable text.

On Mon, 23 Jan 2023 at 01:07, jagged3dge @.***> wrote:

It must be currently possible to use the pattern.matchBuilder to return a WidgetSpan instance to resolve this.

EasyRichText( "choose your language language_icon", patternList: [ EasyRichTextPattern( targetString: 'language_icon', matchBuilder: ((context, match) { return WidgetSpan( child: Container( decoration: const BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.all(Radius.circular(8.0)), ), child: Padding( padding: const EdgeInsets.all(4), child: Icon( Icons.translate, color: Colors.white, ), ), ), ); }), ), ], )

— Reply to this email directly, view it on GitHub https://github.com/2000calories/flutter_easy_rich_text/issues/42#issuecomment-1399497972, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDUBCIIQGBNYT6NU25UJKDWTU5IPANCNFSM6AAAAAAT6MXHPI . You are receiving this because you authored the thread.Message ID: @.***>

jagged3dge commented 1 year ago

@zthrive Indeed. I realized it after I posted and promptly decided to delete my post.

May in future it could be possible to have new API to add prefix/suffix InlineSpan widgets to the output results per match, maybe using builder typedefs.

2000calories commented 1 year ago

@zthrive Indeed. I realized it after I posted and promptly decided to delete my post.

May in future it could be possible to have new API to add prefix/suffix InlineSpan widgets to the output results per match, maybe using builder typedefs.

Thanks. It is a nice feature to have prefix/suffix InlineSpan widgets.

2000calories commented 1 year ago

Upgrade to the lastest 1.2.0 version and try

///add icon before/after targetString
EasyRichText(
  "Please contact us at +123456789",
  patternList: [
    EasyRichTextPattern(
      targetString: EasyRegexPattern.telPattern,
      prefixInlineSpan: WidgetSpan(
        child: Icon(Icons.local_phone),
      ),
      suffixInlineSpan: WidgetSpan(
        child: Icon(Icons.local_phone),
      ),
    )
  ],
),
zthrive commented 1 year ago

Thank you for this. Great work!

On Tue, 28 Feb 2023, 12:35 pm hans.huang, @.***> wrote:

Closed #42 https://github.com/2000calories/flutter_easy_rich_text/issues/42 as completed.

— Reply to this email directly, view it on GitHub https://github.com/2000calories/flutter_easy_rich_text/issues/42#event-8621921117, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDUBCLHPAGGGWOIA7V7KVLWZVI6LANCNFSM6AAAAAAT6MXHPI . You are receiving this because you were mentioned.Message ID: <2000calories/flutter_easy_rich_text/issue/42/issue_event/8621921117@ github.com>

2000calories commented 1 year ago

Thank you for this. Great work! On Tue, 28 Feb 2023, 12:35 pm hans.huang, @.***> wrote: Closed #42 <#42> as completed. — Reply to this email directly, view it on GitHub <#42 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDUBCLHPAGGGWOIA7V7KVLWZVI6LANCNFSM6AAAAAAT6MXHPI . You are receiving this because you were mentioned.Message ID: <2000calories/flutter_easy_rich_text/issue/42/issue_event/8621921117@ github.com>

If you find this package useful, please give it a star flutter_easy_rich_text

zthrive commented 1 year ago

Just did 😀

On Tue, 28 Feb 2023 at 16:48, hans.huang @.***> wrote:

Thank you for this. Great work! … <#m-2432270831142682771> On Tue, 28 Feb 2023, 12:35 pm hans.huang, @.***> wrote: Closed #42 https://github.com/2000calories/flutter_easy_rich_text/issues/42 <#42 https://github.com/2000calories/flutter_easy_rich_text/issues/42> as completed. — Reply to this email directly, view it on GitHub <#42 (comment) https://github.com/2000calories/flutter_easy_rich_text/issues/42#event-8621921117>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDUBCLHPAGGGWOIA7V7KVLWZVI6LANCNFSM6AAAAAAT6MXHPI . You are receiving this because you were mentioned.Message ID: <2000calories/flutter_easy_rich_text/issue/42/issue_event/8621921117@ github.com>

If you find this package useful, please give it a star flutter_easy_rich_text https://github.com/2000calories/flutter_easy_rich_text

— Reply to this email directly, view it on GitHub https://github.com/2000calories/flutter_easy_rich_text/issues/42#issuecomment-1447618957, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDUBCOY3CB52HO43JKBUDLWZWGRRANCNFSM6AAAAAAT6MXHPI . You are receiving this because you were mentioned.Message ID: @.***>