ansi_modifier 0.0.1 ansi_modifier: ^0.0.1 copied to clipboard
Modify strings by adding, clearing, and replacing ANSI modifiers.
Ansi Modifier - Example #
Usage #
The example below shows how the to add, modify, and clear Ansi modifiers.
import 'package:ansi_modifier/src/ansi.dart';
void main(List<String> args) {
/// Create colorized strings.
print('Create colorized strings:');
final blue = 'blueberry'.modify(Ansi.blue + Ansi.italic);
final green = 'green apple'.modify(Ansi.green);
final blueGreen = blue +
' and ' +
green.modify(
Ansi.bold,
method: Replace.none,
);
print('$blue, $green, $blueGreen');
/// Modify a previously colorized string.
print('\nModify previously colorized strings:');
/// Replace first modifier:
final yellowGreen = blueGreen.modify(Ansi.yellow + Ansi.bold + Ansi.underline,
method: Replace.first);
/// Replace all modifiers.
final magenta =
yellowGreen.modify(Ansi.magenta, method: Replace.clearPrevious);
/// Strip all Ansi modifiers.
print('$yellowGreen, $magenta, ${magenta.removeAnsi()}');
}
Features and bugs #
If some Ansi modifiers are missing please file a enhancement request at the issue tracker.