styled_text 1.0.0+1

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.');
      },
    ),
  },
)

1.0.0+1 #

  • Example added.

1.0.0 #

  • Initial release.

example/README.md

StyledText example #

Demonstrates how to use 'Styled Text'.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  styled_text: ^1.0.0+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:styled_text/styled_text.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
34
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

We analyzed this package on Aug 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
xmlstream ^0.11.1 0.11.1
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test