tag_highlight_text 1.0.1 copy "tag_highlight_text: ^1.0.1" to clipboard
tag_highlight_text: ^1.0.1 copied to clipboard

outdated

This library will support highlight text by tags with specific styles and tap actions.

Tag Highlight Text Library #

This library will support highlight text by tags with specific styles and tap actions.

Usage #

To use this package, add tag_highlight_text as a dependency in your pubspec.yaml file.

Example #

Import the library

import 'package:tag_highlight_text/tag_highlight_text.dart';

You need use tags to mark highlight texts

final text = 'This is <highlight>Highlight <bold>Text</bold></highlight>. Click <link>here</link>';

After, call the TagHighlightText widget and define highlightBuilder to set style and tap actions for each tags.

TagHighlightText(
  text: text,
  highlightBuilder: (tagName) {
    switch (tagName) {
      case 'highlight':
        return HighlightData(
          style: TextStyle(
            color: Colors.red,
          ),
        );
      case 'bold':
        return HighlightData(
          style: TextStyle(
            fontWeight: FontWeight.bold,
          ),
        );
      case 'link':
        return HighlightData(
          style: TextStyle(
            color: Colors.blue,
            decoration: TextDecoration.underline,
          ),
          onTap: () {
            print('Click');
          },
        );
    }
  },
  textStyle: TextStyle(
    color: Colors.black,
    fontSize: 18,
  ),
),
12
likes
0
points
1.41k
downloads

Publisher

unverified uploader

Weekly Downloads

This library will support highlight text by tags with specific styles and tap actions.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on tag_highlight_text