TDD in Flutter/Dart. How to reduce start up time TDD in Flutter/Dart. How to reduce start up time flutter flutter

TDD in Flutter/Dart. How to reduce start up time


I've tried running a sample test (using the Flutter demo app) recently, running flutter test through the terminal initializes the test in an instant.

flutter test via terminal

However, I got similar startup time (around 4 seconds) when the tests were run through the UI.

flutter test through UI

I tried digging into the settings and there doesn't seem to be any config that we can modify to make the tests initialize faster compared to what we have at present.

Here's my flutter doctor for reference.

[✓] Flutter (Channel master, 1.26.0-2.0.pre.281, on macOS 11.1 20C69 darwin-x64)    • Flutter version 1.26.0-2.0.pre.281    • Framework revision 4d5db88998 (2 weeks ago), 2021-01-11 10:29:26 -0800    • Engine revision d5cacaa3a6    • Dart version 2.12.0 (build 2.12.0-211.0.dev)[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)    • Platform android-30, build-tools 29.0.2    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)    • All Android licenses accepted.[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)    • Xcode at /Applications/Xcode.app/Contents/Developer    • Xcode 12.0.1, Build version 12A7300    • CocoaPods version 1.10.0[✓] Chrome - develop for the web    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome[✓] Android Studio (version 4.1)    • Android Studio at /Applications/Android Studio.app/Contents    • Flutter plugin can be installed from:      🔨 https://plugins.jetbrains.com/plugin/9212-flutter    • Dart plugin can be installed from:      🔨 https://plugins.jetbrains.com/plugin/6351-dart    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)[✓] VS Code (version 1.52.1)    • VS Code at /Applications/Visual Studio Code.app/Contents    • Flutter extension version 3.18.1[✓] Connected device (1 available)    • Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.96• No issues found!


This method works perfectly for me:

1. flutter run --profile --cache-sksl2. Press M at the command line of flutter run to write the captured SkSL shaders into a file named something like flutter_01.sksl.json.3. Build the app with SkSL warm-up using the following, as appropriate:Android:flutter build apk --bundle-sksl-path flutter_01.sksl.jsonorflutter build appbundle --bundle-sksl-path flutter_01.sksl.jsoniOS:flutter build ios --bundle-sksl-path flutter_01.sksl.jsonFor more information, visit: https://flutter.dev/docs/perf/rendering/shader