styled_text 1.0.1+1

Flutter Android iOS web

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

styled_text #

Text widget with formatting via 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.

Getting Started #

In your flutter project add the dependency:

dependencies:
  ...
  styled_text: ^1.0.0

Import package:

import 'package:styled_text/styled_text.dart';

Usage example #

An example of making parts of text bold:

StyledText(
  text: 'Test: <bold>bold</bold> text.',
  styles: {
    'bold': TextStyle(fontWeight: FontWeight.bold),
  },
)


Example of highlighting a part of the text by different styles:

StyledText(
  text: 'Test: <bold>bold</bold> and <red>red color</red> text.',
  styles: {
    'bold': TextStyle(fontWeight: FontWeight.bold),
    'red': TextStyle(fontWeight: FontWeight.bold, color: Colors.red),
  },
)


Example of inserting icons into the text:

StyledText(
  text: 'Text with alarm <alarm/> icon.',
  styles: {
    'alarm': IconStyle(Icons.alarm),
  },
)


Example of using a tag handler:

StyledText(
  text: 'Text with <link href="https://flutter.dev">link</link> inside.',
  styles: {
    'link': ActionTextStyle(
      decoration: TextDecoration.underline,
      onTap: (TextSpan text, Map<String, String> attrs) => {
        final String link = attrs['href'];
        print('The "$link" link is tapped.');
      },
    ),
  },
)

25
likes
100
pub points
85%
popularity

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

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

chentsov@gmail.com

License

BSD (LICENSE)

Dependencies

flutter, xmlstream

More

Packages that depend on styled_text