GithubHelp home page GithubHelp logo

andyduke / styled_text_package Goto Github PK

View Code? Open in Web Editor NEW
74.0 8.0 48.0 463 KB

Text widget with formatted text using tags. Makes it easier to use formatted text in multilingual applications.

Home Page: https://pub.dev/packages/styled_text

License: BSD 3-Clause "New" or "Revised" License

Objective-C 0.56% Dart 46.10% Shell 0.75% HTML 2.56% Kotlin 0.19% Swift 0.81% CMake 20.06% C++ 27.49% C 1.48%
widget multilingual-applications flutter text formatted-text

styled_text_package's Introduction

StyledText

Text widget with formatted text using tags. Makes it easier to use formatted text in multilingual applications.

Formatting is set in the text using xml tags, for which styles are defined separately. It is also possible to insert icons through tags for which icons are set in styles.

You can set the click handler for the tag, through a special style ActionTextStyle.

See more

styled_text_package's People

Contributors

andyduke avatar cassiuspacheco avatar ryanheise avatar salehhub avatar shredding avatar thomasgysemans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

styled_text_package's Issues

Does it support emoji ?

I have used it like whatsapp formatting text , so if i want to display emoji in text view how can i do that ?

MultiLine Support

Hey! This Widget is awesome <3

I am formatting a loooong text, with lots of new lines... and I am aware that I have to use the breaking tags for new lines, but I was wondering if you could add an option like 'multiLine: true' or something like that, so that we don't have to deal with new lines on multiline strings.

It's just a suggestion for this widget, I don't even know if that's possible, but I hope so! Thank you for your work, it's very useful ^^

Still having build problem with version 3.0.0

The closed issues #32 #31 are still happing in pub.dev 3.0.0 version.

7:7: Error: The non-abstract class 'CustomStyle' is missing implementations for these members:
 - TextStyle.overflow
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 CustomStyle with Diagnosticable implements TextStyle {
      ^^^^^^^^^^^

Apostrophes are not rendered

Using the example, if you add a common single apostrophe ( ' ) in any text, it is not shown running on the web.

Bold Text Accessibility

Hi there,

first of all, thanks for the amazing work. This lib is great!

I managed to make use of the textScaleFactor when using StyledText but I noticed that the bold text accessibility option does not get applied to the text automatically.

Is there a way for me to achieve that at the current state of the lib or will it need extra customisation? If it needs extra customisation, would you be able to give me a bit of a direction to where I should be looking into in order to change this?

Thank you

How is an apostrophe to be placed in a StyledText?

I might have a slightly strange use-case (storing lots of styled text strings as values in json files, so xml in a json file) but I can't seem to find a way to make apostrophes appear. This is true even when I run the example app and try to put a word with an apostrophe in one of the strings.

I've tried using the escape sequence: \' but this has no effect on the output (and would be incorrect when stored in a json file regardless). I've tried using &apos; and #39; but those are just output the way they appear. I also tried using double quotes around the strings and just using regular apostrophes, but those disappear too.

double quotes won't show

How would I show the double quotes? I did use replaceAll that would replace double quote with " but still it won't show.

Removes single and double quotations from the String being displayed.

Say, I want to display.
i.e: Lisa asked Shane "How was the weather?" asked Lisa.
I want to display the quotations marks but it's being trim out and doesn't even leaves the spacing between the words. Like I'''''''''m -> I m but does Im instead.
Also using a raw string does not seem to help.
Ran through the code and saw that I could use [& a p o s ;] in my String to get the ' character but it would be nice to use ' " in the String itself.

Thanks in advance.

fix styled text on Appbar

fix styled text on Appbar while using NestedScrollView ,SliverAppBar,

issue is while using floating on SliverAppBar , when scrolling bottom to top, styled text disappear/not shown,

the code to reproduce the problem.

Scaffold(
      body: NestedScrollView(
        floatHeaderSlivers: true,
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return <Widget>[
            SliverAppBar(
              title: StyledText(
                text: '<b>Sample Items</b>',
                tags: {
                  'b': StyledTextTag(
                      style: const TextStyle(fontWeight: FontWeight.bold)),
                },
              ),
              snap: true,
              pinned: false,
              floating: true,
              actions: <Widget>[
                IconButton(
                  icon: const Icon(Icons.settings),
                  onPressed: () {
                    
                    Navigator.restorablePushNamed(
                        context, SettingsView.routeName);
                  },
                ),
              ],
            ),
          ];
        },
        body:

           
            ListView.builder(
          
          restorationId: 'sampleItemListView',
          itemCount: items.length,
          itemBuilder: (BuildContext context, int index) {
            final item = items[index];

            return Column(
              children: [
                ListTile(
                    title: Text(
                      '''SampleItem ${item.id}
                  styled_text
                    styled_text_tag
                    styled_text_tag_action
                    styled_text_tag_base
                    styled_text_tag_custom
                    styled_text_tag_icon
                    styled_text_tag_widget
                    styled_text_tag_widget''',
                    ),
                    
                    leading: const CircleAvatar(
                      foregroundImage:
                          AssetImage('assets/images/flutter_logo.png'),
                    ),
                    onTap: () {
                      Navigator.restorablePushNamed(
                        context,
                        SampleItemDetailsView.routeName,
                      );
                    }),
                const Divider(
                  color: Colors.grey,
                ),
              ],
            );
          },
        ),
      ),
    );

change items list length to 10 count,

run the app,

when scrolling bottom to top, styled text disappear/not shown,

when it reach top then only ,styled text appear/shown,

when trying same code Text widget , it shows Appbar text.

An example of how handle html tags?

It would be nice to have a sample on how to handle some HTML tags such as <p> <ul> <li> <ol> <blockquote> <h1,2,3,…> etc… maybe a default for each one in the library?

Symbols limit

I insert a long text, but when it rendered, I see part of the text. It's about 824 symbols. So can I insert more text than 824?

TextOverflow.ellipsis for web with maxLines not working

Hi,

I am having an issue with overflow: TextOverflow.ellipsis for web.
I am unable to see ellipsis for my text. The code :
return Container(
alignment: Alignment.topLeft,
child: StyledText(
text: myText,
newLineAsBreaks: true,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 15),
styles: {
'bold': TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15),
'italic': TextStyle(
fontStyle:
FontStyle.italic,
fontSize: 15),
'n': TextStyle(fontSize: 15),
}));

"myText" has multiline text in it. If I change maxLines to 1, I am able to see ellipsis, otherwise I am unable to see ellipsis on overflow of text.
I also tried softwrap: false but that also didn't work.
The above code works fine in Android but not in Web.

Thanks

Add SelectionArea compatibility

Flutter 3.3 added the SelectionArea() widget, allowing all compatible child widget contents to be selectable (and allowing a selection to encompass multiple widgets). The styled_text_package uses an older implementation of .selectable, requiring an explicit per-widget choice of selectable and which is not compatible with SelectionArea().

For your consideration, I would like to suggest a small change in styled_text_package to enable SelectionArea compatibility:

In styled_text.dart, change the RichText() widget on line 369 to a Text.rich() widget, which includes the same functionality as RichText() and also has built-in integration with SelectionArea(). After this change, StyledText() is selectable or not based on whether it is a child widget of a SelectionArea().

Minimal reproducible example:


import 'package:flutter/material.dart';
import 'package:styled_text/styled_text.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                StyledText(
                  text: 'Should not be selectable at all'
                ),
                SelectionArea(
                  child: Column(
                    children: <Widget>[
                      StyledText(
                        text: 'Can this text be selected?',
                      ),
                      StyledText(
                        text: 'How about this one?',
                      ),
                      StyledText(
                        text: '<bold>Or</bold> <italic>this</italic> one<big>?</big>',
                        tags:{
                          'bold': StyledTextTag(
                              style: TextStyle(fontWeight: FontWeight.bold)
                          ),
                          'italic': StyledTextTag(
                              style: TextStyle(fontStyle: FontStyle.italic)
                          ),
                          'big': StyledTextTag(
                              style: TextStyle(fontSize: 24)
                          )
                        }
                      ),
                    ]
                  ),
                ),
              ],
          ),
        ),
      ),
    );
  }
}

Suggested change (lines 369 to 388 in styled_text.dart, just changing to Text.rich and changing span to a positional argument):

return Text.rich(
    span,
    textAlign:
       widget.textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start,
    textDirection: widget.textDirection,
    softWrap: widget.softWrap ?? defaultTextStyle.softWrap,
    overflow: widget.overflow ??
       effectiveTextStyle?.overflow ??
       defaultTextStyle.overflow,
    textScaleFactor:
        widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
    maxLines: widget.maxLines ?? defaultTextStyle.maxLines,
    locale: widget.locale,
    strutStyle: widget.strutStyle,
    textWidthBasis:
        widget.textWidthBasis ?? defaultTextStyle.textWidthBasis,
    textHeightBehavior: widget.textHeightBehavior ??
        defaultTextStyle.textHeightBehavior ??
        DefaultTextHeightBehavior.of(context),
);

Before changing styled_text.dart, the entire text is unselectable. After the suggested change, everything within the SelectionArea() is selectable. My example includes a StyledText() with multiple tags, to show that it still works across text composed of multiple spans.

I love styled_text_package, as it makes complex text formatting so much easier in Flutter. Hopefully this suggestion is implementable. Thanks!

Building after dispose when rolling a list causing exceptions

Hello, first thanks for that magnific package.
My project is throwing the following exception when rolling a ListView (Probabily is building after element hide from list).

E/flutter (15254): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: This widget has been unmounted, so the State no longer has a context (and should be considered defunct).
E/flutter (15254): Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.

line: package:styled_text/styled_text.dart:341

image

Thanks

Error when building app when upgrade flutter

When i try to compile project, i got this error because of upgrading flutter to version 2.1.0-12.2.pre

Error: The method 'CustomStyle.apply' has fewer named arguments than those of overridden method
class 'CustomTextStyle' is missing implementations for these members: - TextStyle.leadingDistribution

maxLines doesn't work for web

Hi,

maxLines for web is not working if the text has multiple line text but the first line isn't long enough for the container that holds the text in it.
ex. If my text has 4 lines but the first line is short, maxLines doesn't work and shows the entire text.

I made changes to Container size to make the maxLine work.
Container(width: (myText.toString().split('\n')[0].length > 70) ? 680 : 600)
Thanks

StyledText does not rebuild when setState updates variables.

I used the widget with the style : StyledText(fontFamily, fontSize and height) properties which gets updated when the user changes these settings but the widget does not adjust to these changes. The hierarchy tree is: Consumer->FutureBuilder->ListView.builder()->ListTile() and within the title property I use the StyledText()

No named parameter with the name 'cursorHeight'

I imported the dependency, tried to run my sample code. I'm seeing No named parameter with the name 'cursorHeight' issue.

Screen Shot 2020-11-23 at 8 05 38 AM
Screen Shot 2020-11-23 at 8 08 26 AM

I took this dependency - https://pub.dev/packages/styled_text/install
I have added my flutter version used and I have also added the screenshot where Run main.dart has given the exception.

To check the usage of styled_text, Locally I removed the reference of cursorHeight entries in styled_text/styled_text.dart. It started working fine. Please have a look.
Screen Shot 2020-11-23 at 9 46 35 AM

Apostrophe character not shown in my text

When I try to show styled text I cannot see apostrophe character:

`StyledText(
text: "Bell'articolo",
TextAlign: TextAlign.left,
style: ArticleTextStyle.getAbstractStyle(text_color: "#000000", font_size: 16),
styles: {
//Text styles
'u': ArticleTextStyle.getAbstractStyle(text_color: "#000000", font_size: 16, is_underline: true),
'b': ArticleTextStyle.getAbstractStyle(text_color: "#000000", font_size: 16, is_bold: true),
'i': ArticleTextStyle.getAbstractStyle(text_color: "#000000", font_size: 16, is_italic: true),
},
)*

Return this: "bellarticolo"

When I use standard Flutter Text() class I see "Bell'articolo" correctly.

Have you ever encountered this problem?

Thanks

3.0.0-beta+2 still gives compile errors on beta channel

styled_text-3.0.0-beta+2/lib/custom_style.dart:7:7: Error: The non-abstract class 'CustomStyle' is missing implementations for these members:
 - TextStyle.leadingDistribution                                        
Try to either                                                           
 - provide an implementation,                                           
 - inherit an implementation from a superclass or mixin,                
 - mark the class as abstract, or                                       
 - provide a 'noSuchMethod' implementation.

...
...

I think this class would need to be deprecated in a lower version, but it would need to be outright removed in the 3.0.0 release otherwise it will never compile on the latest Flutter.

How to apply custom style to all the text?

Hello,

First of all, thanks for your contribution, this is very useful package.
But I would like to apply custom style to all the text,with the parameter 'style', something like that:

StyledText(
text: 'Test: <bold>bold</bold> text.',
style: GoogleFonts.sourceSansPro(
fontSize: 20,
fontWeight: FontWeight.normal,
 ),
 styles: {
 'bold': TextStyle(fontWeight: FontWeight.bold),                              
 },
),

So, is it possible change the default style to all text?. I tried and the text disappears. If I remove the style parameter, then the text appears again.
Thanks!

Unhandled Exception: Bad state: No element

[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Bad state: No element
ListQueue.removeLast (dart:collection/queue.dart:767:25)
_StyledTextState._updateTextSpans. (package:styled_text/styled_text.dart:353:30)
_rootRunUnary (dart:async/zone.dart:1198:47)
_CustomZone.runUnary (dart:async/zone.dart:1100:19)
_CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
_BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
_DelayedData.perform (dart:async/stream_impl.dart:611:14)
_StreamImplEvents.handleNext (dart:async/stream_impl.dart:730:11)
E/flutter (11144): #8 _PendingEvents.schedule. (dart:async/stream_impl.dart:687:7)
_rootRun (dart:async/zone.dart:1182:47)
_CustomZone.run (dart:async/zone.dart:1093:19)
_CustomZone.runGuarded (dart:async/zone.dart:997:7)
_CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23)
_rootRun (dart:async/zone.dart:1190:13)
_CustomZone.run (dart:async/zone.dart:1093:19)
_CustomZone.runGuarded (dart:async/zone.dart:997:7)
_CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23)
_microtaskLoop (dart:async/schedule_microtask.dart:41:21)
_startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

Could you support simple image

Could you support render image tag, like icon tag, render thumbnail image with external link and fullscreen when tap on image. Thank you!

Newline charater doesn't get converted to <br/>

This code works fine:

test = "<b>$name</b> hit <b>someone</b> with <i>a club</i>";
test += "<br/>";
test += "Next line message";

Result:
img1

But this code produces a different result:

test = "<b>$name</b> hit <b>someone</b> with <i>a club</i>";
test += "\n";
test += "Next line message";

Result:
img2

The problem occurs on the latest version: 1.0.3+1

New line character doesn't break text into new line

When I want to format text like this:
"First line text and <link>click here</link>.\n\nSecond line of text.\n\nThird line."

I expect that this text will be drawn in multiple lines, but what I see on my screen is that \n characters are completely ignored. Any ideas on how to overcome this difficulty and use line breaks?

Consectuive interpreted tags within a String that are space-separated will lose the space

Example

I have a description property that is a passed to a StyledText() widget.

One such description reads:
"A finely crafted hat adorned with an inky black strand of <link npc='crow'>Crow</link> <link id='feather'>feather</link>. Well-suited for the hero that strikes from afar."

When rendered in my application, the String has lost the space between the consectuive <link> tags, resulting in:
"A finely crafted hat adorned with an inky black strand of Crowfeather. Well-suited for the hero that strikes from afar."

3.0.4+1 "'CustomStyle.apply' has fewer named arguments" error with master.

Getting a build error on the latest flutter master. Thanks!

../../../../../Development/Packages/flutter-sdk-master/.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.4+1/lib/custom _style.dart:17:13: Error: The method 'CustomStyle.apply' has fewer named arguments than those of overridden method 'TextStyle.apply'. TextStyle apply({ ^ ../../../../../Development/Packages/flutter-sdk-master/packages/flutter/lib/src/painting/text_style.dart:890:13: Context: This is the overridden method ('apply'). TextStyle apply({ ^

Breaking change on Flutter 2.5

Hi,

I Use your awesome package, but since the release of Flutter 2.5, it seems that there is a problem caused by some changes on flutter.

I Have this error:

../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.2/lib/custom_style.dart:8:7: Error: The non-abstract class 'CustomStyle' is missing implementations for these members:

  • TextStyle.overflow
    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 CustomStyle with Diagnosticable implements TextStyle {
^^^^^^^^^^^
../../../development/flutter/packages/flutter/lib/src/painting/text_style.dart:774:23: Context: 'TextStyle.overflow' is defined here.
final TextOverflow? overflow;
^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.2/lib/custom_text_style.dart:34:7: Error: The non-abstract class 'CustomTextStyle' is missing implementations for these members:

  • TextStyle.overflow
    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 CustomTextStyle extends CustomStyle {
^^^^^^^^^^^^^^^
../../../development/flutter/packages/flutter/lib/src/painting/text_style.dart:774:23: Context: 'TextStyle.overflow' is defined here.
final TextOverflow? overflow;
^^^^^^^^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.2/lib/custom_style.dart:17:13: Error: The method 'CustomStyle.apply' has fewer named arguments than those of overridden method 'TextStyle.apply'.
TextStyle apply(
^
../../../development/flutter/packages/flutter/lib/src/painting/text_style.dart:876:13: Context: This is the overridden method ('apply').
TextStyle apply({
^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.2/lib/custom_style.dart:17:13: Error: The method 'CustomStyle.apply' doesn't have the named parameter 'overflow' of overridden method 'TextStyle.apply'.
TextStyle apply(
^
../../../development/flutter/packages/flutter/lib/src/painting/text_style.dart:876:13: Context: This is the overridden method ('apply').
TextStyle apply({
^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.2/lib/custom_style.dart:85:13: Error: The method 'CustomStyle.copyWith' has fewer named arguments than those of overridden method 'TextStyle.copyWith'.
TextStyle copyWith(
^
../../../development/flutter/packages/flutter/lib/src/painting/text_style.dart:785:13: Context: This is the overridden method ('copyWith').
TextStyle copyWith({
^
../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.2/lib/custom_style.dart:85:13: Error: The method 'CustomStyle.copyWith' doesn't have the named parameter 'overflow' of overridden method 'TextStyle.copyWith'.
TextStyle copyWith(
^
../../../development/flutter/packages/flutter/lib/src/painting/text_style.dart:785:13: Context: This is the overridden method ('copyWith').
TextStyle copyWith({
^

Maybe it's just a wrong manipulation on my side but is it possible to add the missing implementation ?

Thanks a lot for your time

fix smooth scrolling issue on android

scrolling issue on android

while scrolling from bottom to top/up, its jump to previous ListTile,

the code to reproduce the problem,

create fresh app using "flutter create -t skeleton my_app"

just replace code using styled_text on "sample_item_list_view.dart" file

replace this code

return ListTile(
            title: Text('SampleItem ${item.id}'),
            leading: const CircleAvatar(
              // Display the Flutter Logo image asset.
              foregroundImage: AssetImage('assets/images/flutter_logo.png'),
            ),
            onTap: () {
              // Navigate to the details page. If the user leaves and returns to
              // the app after it has been killed while running in the
              // background, the navigation stack is restored.
              Navigator.restorablePushNamed(
                context,
                SampleItemDetailsView.routeName,
              );
            }
          );

with

return Column(
           children: [
             ListTile(
                 title: StyledText(
                   text: '''<b>SampleItem ${item.id}</b>
                   styled_text
                   styled_text_tag
                   styled_text_tag_action
                   styled_text_tag_base
                   styled_text_tag_custom
                   styled_text_tag_icon
                   styled_text_tag_widget
                   styled_text_tag_widget''',
                   newLineAsBreaks: true,
                   tags: {
                     'b': StyledTextTag(
                         style: TextStyle(fontWeight: FontWeight.bold)),
                   },
                 ),
                 //  Text('SampleItem ${item.id}'),
                 leading: const CircleAvatar(
                  
                   foregroundImage:
                       AssetImage('assets/images/flutter_logo.png'),
                 ),
                 onTap: () {
                  
                   Navigator.restorablePushNamed(
                     context,
                     SampleItemDetailsView.routeName,
                   );
                 }),
             const Divider(
               color: Colors.grey,
             ),
           ],
         );

change items list length to 30 count,

now build the app and run on android devices,

while scrolling to bottom, it scrolls fine,

but slowly scroll up/top , 'ListTile' get jump/skip to previous.

same code made with normal Text widget (except style), it scrolls fine.

return Column(
            children: [
              ListTile(
                  title: Text(
                    '''SampleItem ${item.id}
                  styled_text
                    styled_text_tag
                    styled_text_tag_action
                    styled_text_tag_base
                    styled_text_tag_custom
                    styled_text_tag_icon
                    styled_text_tag_widget
                    styled_text_tag_widget''',
                  ),
                 
                  leading: const CircleAvatar(
                    foregroundImage:
                        AssetImage('assets/images/flutter_logo.png'),
                  ),
                  onTap: () {
                    Navigator.restorablePushNamed(
                      context,
                      SampleItemDetailsView.routeName,
                    );
                  }),
              const Divider(
                color: Colors.grey,
              ),
            ],
          );

fix theme issue while changing light to dark theme

Hi dev,

first of all, thanks for the great work.

issue is while changing light to dark theme, styled_text text remain as light theme text color, when scrolling styled_text text changed to dark theme text color.

styled_text not working with theme changing.

IconStyle() is limited and does not provide any properties for customization of presentation

Rudimentary Workaround

Suggestion:

class IconStyle extends TextStyle {
    /// Icon to insert into text
    final IconData icon;
    final Color color;
    final double size;
    final Color backgroundColor;

    IconStyle(this.icon,
        {this.color = const Color(0xFFFFFFFF),    // or something
        this.size = 24,    // or something
        this.backgroundColor = const Color(0x00000000),    // or something
    });
}
if (style is IconStyle) {
    node = TextSpan(
        text: String.fromCharCode(style.icon.codePoint),
        style: TextStyle(
            fontFamily: style.icon.fontFamily,
            package: style.icon.fontPackage,
            color: style.color,
            fontSize: style.size,
            backgroundColor: style.backgroundColor,
        ),
    );
}

Color with hex values

The API I'm using is returning this:

Attack primary target for <color=#86e619>80%</color> damage.\nGain <color=#fff568>Offense Up</color> + apply <color=#fff568>Offense Up</color> to adjacent <color=#fff568>A.I.M.</color> allies for <color=#86e619>2</color> turns.\n\nThis attack cannot miss.

Would be nice if this package can handle that kind of tag

Error on update to version 2.0.0 for null safety: `CustomTextStyle ` & `leadingDistribution` & `copyWith`

BUG Description

I am trying to migrate to null safety and currently using:
Flutter 2.2.0-10.2.pre & Flutter 2.0.6
Dart 2.12.4 (stable)
styled_text_package: 2.0.0

I get this error code and don't know what to do :(

Terminal Build Error Code

Launching lib/main.dart on iPhone 8 in debug mode...
Xcode build done.                                           16,8s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    ../../../.pub-cache/hosted/pub.dartlang.org/styled_text-2.0.0/lib/custom_style.dart:6:7: Error: The non-abstract class 'CustomStyle' is missing implementations for these members:
     - TextStyle.leadingDistribution
    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 CustomStyle with Diagnosticable implements TextStyle {
          ^^^^^^^^^^^
    ../../../fvm/versions/2.2.0-10.2.pre/packages/flutter/lib/src/painting/text_style.dart:630:37: Context: 'TextStyle.leadingDistribution' is defined here.
      final ui.TextLeadingDistribution? leadingDistribution;
                                        ^^^^^^^^^^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dartlang.org/styled_text-2.0.0/lib/custom_text_style.dart:33:7: Error: The non-abstract class 'CustomTextStyle' is missing implementations for these members:
     - TextStyle.leadingDistribution
    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 CustomTextStyle extends CustomStyle {
          ^^^^^^^^^^^^^^^
    ../../../fvm/versions/2.2.0-10.2.pre/packages/flutter/lib/src/painting/text_style.dart:630:37: Context: 'TextStyle.leadingDistribution' is defined here.
      final ui.TextLeadingDistribution? leadingDistribution;
                                        ^^^^^^^^^^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dartlang.org/styled_text-2.0.0/lib/custom_style.dart:15:13: Error: The method 'CustomStyle.apply' has fewer named arguments than those of overridden method 'TextStyle.apply'.
      TextStyle apply(
                ^
    ../../../fvm/versions/2.2.0-10.2.pre/packages/flutter/lib/src/painting/text_style.dart:859:13: Context: This is the overridden method ('apply').
      TextStyle apply({
                ^
    ../../../.pub-cache/hosted/pub.dartlang.org/styled_text-2.0.0/lib/custom_style.dart:15:13: Error: The method 'CustomStyle.apply' doesn't have the named parameter 'leadingDistribution' of overridden method 'TextStyle.apply'.
      TextStyle apply(
                ^
    ../../../fvm/versions/2.2.0-10.2.pre/packages/flutter/lib/src/painting/text_style.dart:859:13: Context: This is the overridden method ('apply').
      TextStyle apply({
                ^
    ../../../.pub-cache/hosted/pub.dartlang.org/styled_text-2.0.0/lib/custom_style.dart:81:13: Error: The method 'CustomStyle.copyWith' has fewer named arguments than those of overridden method 'TextStyle.copyWith'.
      TextStyle copyWith(
                ^
    ../../../fvm/versions/2.2.0-10.2.pre/packages/flutter/lib/src/painting/text_style.dart:770:13: Context: This is the overridden method ('copyWith').
      TextStyle copyWith({
                ^
    ../../../.pub-cache/hosted/pub.dartlang.org/styled_text-2.0.0/lib/custom_style.dart:81:13: Error: The method 'CustomStyle.copyWith' doesn't have the named parameter 'leadingDistribution' of overridden method 'TextStyle.copyWith'.
      TextStyle copyWith(
                ^
    ../../../fvm/versions/2.2.0-10.2.pre/packages/flutter/lib/src/painting/text_style.dart:770:13: Context: This is the overridden method ('copyWith').
      TextStyle copyWith({
                ^

Do not return the text pressed

Before this worked well on version 1.0.1:

'f': ActionTextStyle(
onTap: (TextSpan texto, Map<String, String> attrs) =>
_openRef(context, texto, attrs),
),

Now, on version 3.03; texto does not receive or returns anything :
'f': StyledTextActionTag(
(texto, _) {
selectRef = true;
print('SELECCIONADO REFERENCIA, valor = $texto'); //texto = null
_openRef(context, texto);
},
),

I need help please.
I need to get the value within a text </ f> and then process it on my own.
Thanks

Ability to insert a WidgetSpan in a StyledText

This package is very usefull, especially for internationalization, however I have an use case where I can't use it : WidgetSpans.

I was using RichText (without translations) before and I added a sort of Chip with an avatar and a name in a WidgetSpan.

I didn't find a way to use StyledText with WidgetSpan but that would be really cool !

Is there a way that I missed ?

Custom Style: No named parameter with the name 'overflow'

I find this error when running the project using this code snippet with flutter 2.2.1

Code snippet:
StyledText( text: 'Example: <b>bold</b> text.', tags: { 'b': StyledTextTag(style: TextStyle(fontWeight: FontWeight.bold)), }, )

Error:
../../../.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.4/lib/custom_style.dart:69:7: Error: No named parameter with the name 'overflow'.
overflow: overflow,
^^^^^^^^
../../../.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.4/lib/custom_style.dart:138:7: Error: No named parameter with the name 'overflow'.
overflow: overflow,
^^^^^^^^
../../../.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.4/lib/custom_style.dart:253:39: Error: The getter 'overflow' isn't defined for the class 'TextStyle'.

  • 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('../../../fvm/versions/2.2.1/packages/flutter/lib/src/painting/text_style.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'overflow'.
    TextOverflow? get overflow => style.overflow;
    ^^^^^^^^

FAILURE: Build failed with an exception.

  • Where:
    Script '/Users/guibson/fvm/versions/2.2.1/packages/flutter_tools/gradle/flutter.gradle' line: 1035

  • What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command '/Users/guibson/fvm/versions/2.2.1/bin/flutter'' 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 14s

Better documentation

Many things what i want to use in the project, like a break line, don't are in documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.