Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print colored logs in Flutter or Dart projects?

In Flutter or Dart projects texts printed with print function are colored like other texts. How to print colored texts? My editor is VSCode.

like image 396
Abduraimbek Yarkinov Avatar asked Nov 29 '25 18:11

Abduraimbek Yarkinov


1 Answers

There is a package named logger which prints texts colored and well structured. You can use it as following:

import 'package:logger/logger.dart';

void main() {
  final logger = Logger();

  logger.e('Error');
  logger.i('Info');
  logger.w('Warning');
  logger.d('Debug');
  logger.f('Fatal');
  logger.log(Level.error, 'Error message');
}

The result in the console:

In the console you can see easily your logs

like image 86
Abduraimbek Yarkinov Avatar answered Dec 01 '25 06:12

Abduraimbek Yarkinov