15
votes

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...

8
I think that's a normal behavior, if you need to run it on release mode use: flutter run --releaseHosar

8 Answers

24
votes

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

6
votes

From Run→Edit Configurations, you can create two configurations (copy and paste the first, then rename) add additional’s arguments as --debug for debug an --release for release and chose one of those to start your app in Debug mode or Release mode (Let gradle to build for you :) ).

enter image description here

5
votes

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:

  • Release mode:

    flutter run --release
    
  • Profile mode:

    flutter run --profile
    
4
votes

If you build your apps in vsCode. Then, open your terminal(CTRL + `) and type a command.

flutter run --release
2
votes

To remove the flutter debug banner, there are several possibilities :

1- The first one is to use the debugShowCheckModeBanner property in your MaterialApp widget .

Code :

MaterialApp(
  debugShowCheckedModeBanner: false,
) 

And then do a hot reload.

2-The second possibility is to hide debug mode banner in Flutter Inspector if you use Android Studio or IntelliJ IDEA .

enter image description here

3- The third possibility is to use Dart DevTools .


But if you want to switch to release mode ,

Use this command for running your app flutter run --release

or In Android Studio , click on :

> Run
> Flutter Run 'main.dart' in Release Mode

enter image description here

1
votes

I always prefer to learn shortcuts

You can use the following Shortcuts to open the configuration of the run and write --release

ALTSHIFTF10 then Press 0 and Press ALTa

Finally, you are there where you just have to write --release and Press ENTER

Thats it!

0
votes

If you want to just get rid of the debug tag from the rightmost corner of the app, u can use the

this =>  debugShowCheckedModeBanner: false

into your main.dart file in the material app widget.

0
votes

I only change package name at /android/app/src/main/kotlin/MainActivity.kt as the same with applicationID at /android/app/build.gradle, and now it's running...