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.
🎥 Video Tutorial
🛠️ Dependencies
🔭 Implementation
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.
- Try creating separate instances for
success
(green color),error
(red color) andwarning
(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
Check out all my Flutter related blogs here.,👇
Other articles you may like.,
🔵Setting up your Flutter app for publishing in Play Store.
🔴Confetti Animation in Flutter
🟡 Change App Launcher Icon in Flutter
🔴 AnimatedContainer Widget in Flutter
Most popular
Flutter Tutorials
If you found this article useful and wish to support my work, you can consider buying me a ☕️ coffee.👇
If you want to know more about Flutter and various Widgets in Flutter…?🤓 Then visit my channel 👉🏻 vijaycreations🚩
Thanks.,