Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App running on debug mode only for Flutter

I am not sure what is wrong with my Android Studio IDE, but whenever I run the app inside flutter it always runs on debug mode. Please see the label on the right side of the corner.

enter image description here

Logs:

Launching lib\main.dart on POCO F1 in debug mode...

Initializing gradle... Resolving dependencies... Running Gradle task 'assembleDebug'... Built build\app\outputs\apk\debug\app-debug.apk. Installing build\app\outputs\apk\app.apk... Syncing files to device POCO F1...

like image 418
Jitesh Mohite Avatar asked May 17 '19 03:05

Jitesh Mohite


People also ask

How do you write code only for debug mode in flutter?

“flutter only on debug mode” Code Answer'sOn your MaterialApp set debugShowCheckedModeBanner to false.


2 Answers

Have you tried running your code in "release" mode?

Within a terminal you can do that via flutter run --release.

In Android Studio you could double tap shift to bring up the search everywhere command window. If you simply type release you should be able to find the Flutter Run main.dart in Release Mode command.

enter image description here

Also you can find this in the menu under "Run" just like so:

enter image description here

like image 140
Robin Reiter Avatar answered Sep 28 '22 00:09

Robin Reiter


  • Running commands:

    App by default runs on debug mode, it is bit janky but needed to provide features like hot reload and hot restart. However, if you want to run the app in other modes, try these commands:

    1. Release mode:

      flutter run --release
      
    2. Profile mode:

      flutter run --profile
      

  • Adding flags in the IDE:

    You can also add these flags in IDE, click on main.dart in the toolbar:

    enter image description here

    Add --release flag in the Additional run flags option

    enter image description here

like image 20
CopsOnRoad Avatar answered Sep 27 '22 23:09

CopsOnRoad