vijaycreations
Published in

vijaycreations

Change your text color in terminal | Flutter debugging | Package

In this article we will discuss about how to change the text color in terminal in flutter apps.

With the help of the above package we can distinguish our print statements from other text in debug console.

We can basically provide green, red, yellow colors for text data (to indicate success, failure or warning status messages respectively). Apart from theses colors we can also provide RGB values to specify other colors.

  1. Try creating separate instances for success(green color), error(red color) and warning(yellow color) status as shown below.
AnsiPen info = AnsiPen()..blue(bold: true);
AnsiPen success = AnsiPen()..green(bold: true);
AnsiPen warning = AnsiPen()..yellow(bold: true);
AnsiPen error = AnsiPen()..red(bold: true);

2. Now wrap the printable text data inside any of the above status. (success/error/warning). Make sure to set the ansiColorDisabled as false.

  @override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildAppBar(appBarTitle: title),
body: Center(
child: PrimaryBtn(
btnFun: () {
ansiColorDisabled = false;
debugPrint(success('✅ Success'));
},
btnText: 'Print Success',
)),
);
}

Well that’s it. 🎉 Run the code to see it in action.🥳

Refer my video tutorial for complete guide:👉 https://youtu.be/WnE7f_9ycQQ

Get the complete source code here:👉 https://github.com/vijayinyoutube/ansicolor_app

--

--

A list of Flutter Tutorials and app templates

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vijay R

Hai👋 I’m a flutter developer experienced in designing and developing stunning mobile apps. Reach out for freelance projects: vijaycreations02@gmail.com