Home > Back-end >  How to hide/disable print() statements in the release/production mode in a flutter project?
How to hide/disable print() statements in the release/production mode in a flutter project?

Time:12-01

There are many print statements used in the flutter project, How to disable all those statements in the release/Production mode so that they are not displayed on console.

CodePudding user response:

use debugPrint() then it will not print logs in release/profile builds

CodePudding user response:

Next time use debugPrint() or log() to print statements on console so they are not displayed in release and profile builds.

For now, use this little trick to delete all of your print statements at once. In your IDE, press Ctrl Shift R to find and replace strings used in your project. Make sure to select your project scope lib/ folder mainly and enable "Search with Regex" option.

Find: print(.*) (This is a regular expression to select every print statement)

Replace it with:

Hit replace all button and you're good to go.

  • Related