Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between 'flutter run', 'flutter build', Start Debugging, Run Without Debugging, etc

I am new to Flutter. There are different ways to run your app in Flutter. I am wondering what the differences are between these ways. I'm using Visual Studio Code on MacOS.

Way 1

Visual Studio --> Run --> Start Debugging(^F5)

(Is there any command line equivalent of this? Knowing its command line equivalent will be helpful to make things more clear.)

Way 2

Visual Studio --> Run --> Run Without Debugging(^F5)

(Is there any command line equivalent of this? Knowing its command line equivalent will be helpful to make things more clear.)

Way 3

command line --> flutter run

(Is it same with way 2?)

Way 4

command line --> flutter run --release ( I never used this command line, I always use Xcode traditional way to release my app)

Way 5

command line --> flutter run --profile

(I never used this command line, is it slow?)

Way 6

command line --> flutter build <target>

(I never used this command line, is it good or bad? Do you suggest?)

I never set breakpoints when I write code... I always use logging technique(print()) to develop my app.

Which way is the best for me? Which is the fastest? Pros & Cons?

Thanks..

like image 905
gurkan stack Avatar asked Aug 03 '26 07:08

gurkan stack


1 Answers

Given the following Flutter's build modes:

DEBUG MODE MEANS THAT:

  • Assertions are enabled.
  • Service extensions are enabled.
  • Compilation is optimized for fast development and run cycles (but not for execution speed, binary size, or deployment).
  • Debugging is enabled, and tools supporting source-level debugging (such as DevTools) can connect to the process.
  • The build is not minified and tree shaking has not been performed (web only).
  • The app is compiled with the dartdevc compiler for easier debugging (web only).

RELEASE MODE MEANS THAT:

  • Assertions are disabled.
  • Debugging information is stripped out.
  • Debugging is disabled.
  • Compilation is optimized for fast startup, fast execution, and small package sizes.
  • Service extensions are disabled.
  • The build is minified and tree shaking has been performed (web only).
  • The app is compiled with the dart2js compiler for best performance (web only).

PROFILE MODE MEANS THAT

  • Some service extensions, such as the one that enables the performance overlay, are enabled.
  • Tracing is enabled, and tools supporting source-level debugging (such as DevTools) can connect to the process.
  • The build is not minified but tree shaking has been performed (web only).
  • The app is compiled with the dart2js compiler (web only).

So, to answer the question:

  1. Visual Studio --> Run --> Start Debugging(^F5)

    This runs the app like flutter run but in debugging mode. I.e. breakpoints will pause the execution of the app if it reaches one of them.

    There is no command line equivalent for this one.

  2. Visual Studio --> Run --> Run Without Debugging(^F5)

    The same as the 1st one but breakpoints are ignored. Equivalent to flutter run.

  3. command line --> flutter run

    The same as the 2nd one

  4. command line --> flutter run --release

    This runs the app in release mode. I.e. It ignores all asserts (strips them off the final app) and the global vars kDebugMode and kReleaseMode are false and true respectively.

  5. command line --> flutter run --profile

    This includes performance profiling info in the built app. Generally, it makes the app slower than the other options.

  6. command line --> flutter build <target>

    Builds the app for a specific target platform. It's good to use in a CI environment.

Breakpoints are superior as you can trigger them on a condition and even change values at runtime. But a mixture of them is pretty OK.

like image 187
lepsch Avatar answered Aug 05 '26 11:08

lepsch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!