tag_highlight_text

Creator: coderz1093

Last updated:

0 purchases

tag_highlight_text Image
tag_highlight_text Images

Languages

Categories

Add to Cart

Description:

tag highlight text

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';
copied to clipboard
You need use tags to mark highlight texts
final text = 'This is <highlight>Highlight <bold>Text</bold></highlight>. Click <link>here</link>';
copied to clipboard
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: (text) {
print('Click ' + text);
},
);
return null;
}
},
textStyle: TextStyle(
color: Colors.black,
fontSize: 18,
),
),
copied to clipboard
You can custom build content of mark highlight texts by builder
TagHighlightText(
text: text,
highlightBuilder: (tagName) {
switch (tagName) {
case 'highlight':
return HighlightData(
builder: (text) => WidgetSpan(
child: CupertinoButton(
onPressed: () {
// TODO
},
child: Text(text),
),
),
);
return null;
}
},
textStyle: TextStyle(
color: Colors.black,
fontSize: 18,
),
),
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.