Skip to content Skip to sidebar Skip to footer

Avoid `print` calls in production code Flutter


I started seeing this warning in all my print statements.
print('Hello World');


It is because of the flutter_lints package which is implicitly added to new projects created after Flutter 2.3.0.

You can use any of the following solutions.

1. Use debugPrint

debugPrint('Hello World');

2. To remove the warning in that single line:

// ignore: avoid_print 
print('Hello World');

3. To remove the warning in that file

// ignore_for_file: avoid_print
print('Hello World');

4. To remove the warning from the whole project.

Open analysis_options.yaml file and add this linter rule:

include: package:flutter_lints/flutter.yaml

    avoid_print: false

Post a Comment for "Avoid `print` calls in production code Flutter"