Home > Mobile >  Avoid `print` calls in production code. (Documentation)
Avoid `print` calls in production code. (Documentation)

Time:10-12

I started seeing this warning in all my print statements.

print('Foo'); // Warning: Avoid `print` calls in production code. 

CodePudding user response:

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. To remove the warning in that single line:

    // ignore: avoid_print
    print('Hello World');
    
  2. To remove the warning in that file

    // ignore_for_file: avoid_print
    print('Hello World');
    
  3. To remove the warning from the whole project.

    Open analysis_options.yaml file and add this linter rule:

    include: package:flutter_lints/flutter.yaml
    
    linter:
      rules:
        avoid_print: false
    

CodePudding user response:

You could try using debugPrint(); instead

  • Related