skip to Main Content

I am just following the tutorial, but why is the result different?

I don’t know why it’s not working, while my teacher can do it. I’ve searched through ChatGPT and others, but still couldn’t find a solution. I just want my program to run.

2

Answers


  1. You can use print, it will print since it’s just a warning.

    The warning said you shouldn’t use print() in production code. print() will print logs in release builds as well, which is something that shouldn’t happen as some developers might log sensitive information.

    You can get rid of the warning with below solution:

    1. To remove the warning in that single line
    // ignore: avoid_print
    print('Hello World');
    
    1. To remove the warning in that file
    // ignore_for_file: avoid_print
    print('Hello World');
    
    1. 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
    
    Login or Signup to reply.
  2. That’s not a good practice to use print() in production code.

    Instead you can try using logger package, that is also a lot comfortable to use.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search