vivid_text 0.0.1 copy "vivid_text: ^0.0.1" to clipboard
vivid_text: ^0.0.1 copied to clipboard

A great solution for generating "mixed typesetting of text and widget" based on text.

vivid_text #

A great solution for generating "mixed typesetting of text and widget" based on text.

Example #

final List<VividTag> tags = [
    VividWidgetTag(
    name: 'user',
    builder: ((child, attributes) {
        final name = attributes['name'];
        return TextButton(
            onPressed: () {
            final user = getUserApi(int.parse(attributes['userid'] ?? '0'));
            Navigator.push(context, MaterialPageRoute(builder: (c) => UserPage(user)));
            },
            child: Text('$name', style: const TextStyle(fontSize: 18)));
    }),
    ),
    VividWidgetTag(
    name: 'star',
    builder: ((child, attributes) {
        return Icon(Icons.star, color: Colors.yellow[700]);
    }),
    ),
    VividTextTag(
    name: 'hoursToNow',
    builder: ((child, attributes) {
        final time = DateTime.fromMillisecondsSinceEpoch(int.parse(attributes['time']!));
        return TextSpan(text: '${time.hour}');
    }),
    ),
];
final logs = [
    '<user userid="1" name="keysking"></user> created this library <hoursToNow time="1656589103"></hoursToNow> hours ago',
    '<user userid="2" name="Jobs"></user> <star></star> this library <hoursToNow time="1656589103"></hoursToNow> hours ago',
    '<user userid="1" name="keysking"></user> created this library <hoursToNow time="1656589103"></hoursToNow> hours ago',
];
VividText(logs[index], tags: tags, style: const TextStyle(fontSize: 18))
2
likes
120
pub points
0%
popularity

Publisher

verified publisherkeysking.com

A great solution for generating "mixed typesetting of text and widget" based on text.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, html

More

Packages that depend on vivid_text