vivid_text

Creator: coderz1093

Last updated:

0 purchases

vivid_text Image
vivid_text Images

Languages

Categories

Add to Cart

Description:

vivid 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}');
}),
),
];
copied to clipboard
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',
];
copied to clipboard
VividText(logs[index], tags: tags, style: const TextStyle(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.