Flutter build performance
Skill almasumdev/awesome-flutter-agent-skills/.github/skills/performance/flutter-build-performance
Curated agent skills, conventions, and workflows for building Flutter apps with AI coding agents.
npx -y skills add almasumdev/awesome-flutter-agent-skills --skill flutter-build-performanceAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Debug and optimize flutter build times, codegen (build_runner), and CI pipelines. Use this when builds are slow locally or in CI.
SKILL.md
3.2 KB, as published. Nobody here has run it
Flutter Build Performance
Instructions
Slow builds compound across every edit-run cycle and every CI job. Diagnose before you tweak.
1. Profile the Build
- Use
flutter build apk --verbose/--profileand look for the longest phase (Gradle, Kotlin compile, Dart compile, asset bundling). - Gradle:
./gradlew :app:assembleDebug --profilegenerates an HTML report underbuild/reports/profile/. - For Dart-side iteration: prefer hot reload (
r) and hot restart (R) — rebuilding the whole app is almost never necessary during development.
2. Gradle / Android
- Enable the Gradle build cache and parallel execution in
android/gradle.properties:org.gradle.parallel=true org.gradle.caching=true org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 - Keep Android Gradle Plugin and Kotlin up to date (use the versions recommended by the current Flutter stable).
- Avoid multi-dex unless required; keep
minSdkreasonable. - Reduce
ndk { abiFilters }during local dev (e.g., only your device ABI).
3. iOS / CocoaPods
pod install --repo-updateonly when lockfile changes; otherwisepod install.- Commit
Podfile.lock. Useuse_frameworks!with:linkage => :staticto shrink binary and shorten link times. - Enable new build system and incremental installs in Xcode. Clean only when necessary (
flutter cleaninvalidates all caches).
4. build_runner Codegen
freezed, json_serializable, drift, retrofit, riverpod_generator all use build_runner.
- Prefer
dart run build_runner watch --delete-conflicting-outputsduring development. - For one-off:
dart run build_runner build --delete-conflicting-outputs. - Keep generated files out of version control where possible (add to
.gitignore):*.g.dart,*.freezed.dart. Regenerate in CI before tests. - Scope builders in
build.yamlto narrow globs so unrelated file changes do not retrigger generation.
5. Assets and Fonts
- Deduplicate images and compress (
cwebp,pngquant). - Use asset variants (
2.0x/,3.0x/) only for images that need pixel density scaling. - Keep
pubspec.yamlasset entries specific (list files, not whole folders) to avoid re-bundling everything on any asset change.
6. Dependencies
- Audit with
flutter pub depsandflutter pub outdated. - Remove unused packages. Each plugin adds native compile time.
- Pin heavy dev-only tools (linters, codegen) under
dev_dependencies.
7. CI
- Cache
~/.pub-cache,~/.gradle/caches,~/Library/Developer/Xcode/DerivedData(mac runners), and Flutter SDK. - Run
flutter pub getwith a lockfile (pubspec.lockcommitted for apps, not for packages). - Split jobs: analyze + test on Linux, build iOS only when needed.
8. Checklist
- Gradle parallel + caching enabled.
- Hot reload works for your feature (no forced full rebuild).
-
build_runneris watched, not re-run manually each time. - No unused packages in
pubspec.yaml. - CI caches Pub, Gradle, and CocoaPods.