40

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

1
  • 2
    I think that's a normal behavior, if you need to run it on release mode use: flutter run --release Commented May 17, 2019 at 4:46

10 Answers 10

62

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

Sign up to request clarification or add additional context in comments.

Comments

29
  • 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

Comments

15

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

Comments

7

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

flutter run --release

Comments

5

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

Comments

4

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!

Comments

1

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

Comments

0

Open the launch.json file in VS Code.

If you do not have a launch.json file, go to the Run view in VS Code and click create a launch.json file.

In the configurations section, change the flutter Mode property to the build mode you want to target. For example, if you want to run in debug mode, your launch.json might look like this:

 "configurations": [
    {
      "name": "Flutter",
      "request": "launch",
      "type": "dart",
      "flutterMode": "debug"
    }
   ]

Run the app through the Run view.

Comments

0

if you have a different environment to run you can use command like

flutter run --release -t \lib\main.dart

flutter run --release -t \lib\main_staging.dart

"-t" is the target file to run the app

Comments

-2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.