decoratable_text 0.2.2
decoratable_text: ^0.2.2 copied to clipboard
Decorate a part of the text, such as changing the style and setting a tap action.
decoratable_text #
Decorate a part of the text, such as changing the style and setting a tap action.
Installing #
https://pub.dev/packages/decoratable_text#-installing-tab-
Usage #
- Decorate url text
...
const DecoratableText(
text: "url: https://flutter.dev/",
decorations: [
DecorationOption(
pattern: TextPattern.url,
style: TextStyle(color: Colors.blue),
tapAction: TapAction.launchUrl,
showRipple: true,
),
],
),
...
copied to clipboard

- Decorate mail text
...
const DecoratableText(
text: "mail: hogehoge@foomail.com",
decorations: [
DecorationOption(
pattern: TextPattern.mail,
style: TextStyle(color: Colors.blue),
tapAction: TapAction.launchMail,
showRipple: true,
),
],
),
...
copied to clipboard

- Decorate url text and change url display
const DecoratableText(
text:
"You can change the text that matches the pattern. -> https://flutter.dev/",
decorations: [
DecorationOption(
pattern: TextPattern.url,
displayText: "Tap hare",
style: TextStyle(color: Colors.blue),
tapAction: TapAction.launchUrl,
showRipple: true,
),
],
),
copied to clipboard

- Decorate any text
DecoratableText(
text: "You can set custom tap actions. #SnackBar",
decorations: [
DecorationOption(
pattern: r"#[a-zA-Z0-9_]+",
style: TextStyle(color: Colors.teal),
onTap: () => Scaffold.of(context).showSnackBar(
const SnackBar(
content: Text("Tapped #SnackBar"),
),
),
showRipple: true,
),
],
),
copied to clipboard

- Decorate multiple texts
const DecoratableText(
text:
"You can set multiple decoration options. \nFlutter: https://flutter.dev/ #flutter \nDart: https://dart.dev/ #dart",
decorations: [
DecorationOption(
pattern: r"#[a-zA-Z0-9_]+",
style: _tagStyle,
),
DecorationOption(
pattern: TextPattern.url,
style: _linkStyle,
tapAction: TapAction.launchUrl,
showRipple: true,
),
],
),
copied to clipboard