Agent SkillsMimicHunterZ/PocketMind › flutter-app-size

flutter-app-size

GitHub

分析并优化 Flutter 应用包体积,通过构建分析与 DevTools 报告定位大组件,实施调试信息分离、资源压缩及平台特定树摇等策略以减小 APK/IPA 大小。

.claude/skills/flutter-app-size/SKILL.md MimicHunterZ/PocketMind

Trigger Scenarios

需要测量或减少 Flutter 应用包(APK/IPA)的大小 分析应用组件体积构成以进行优化

Install

npx skills add MimicHunterZ/PocketMind --skill flutter-app-size -g -y
More Options

Non-standard path

npx skills add https://github.com/MimicHunterZ/PocketMind/tree/master/.claude/skills/flutter-app-size -g -y

Use without installing

npx skills use MimicHunterZ/PocketMind@flutter-app-size

指定 Agent (Claude Code)

npx skills add MimicHunterZ/PocketMind --skill flutter-app-size -a claude-code -g -y

安装 repo 全部 skill

npx skills add MimicHunterZ/PocketMind --all -g -y

预览 repo 内 skill

npx skills add MimicHunterZ/PocketMind --list

SKILL.md

Frontmatter
{
    "name": "flutter-app-size",
    "metadata": {
        "model": "models\/gemini-3.1-pro-preview",
        "last_modified": "Wed, 04 Mar 2026 22:08:14 GMT"
    },
    "description": "Measure and reduce the size of the Flutter app bundle, APK, or IPA"
}

flutter-app-size-optimization

Goal

Analyzes and optimizes Flutter application size by measuring build artifacts, generating size analysis reports, utilizing Dart DevTools for component breakdown, and implementing specific size reduction strategies such as debug info splitting, resource compression, and platform-specific tree-shaking. Assumes a configured Flutter environment and target platform availability.

Decision Logic

Use the following decision tree to determine the correct measurement and optimization path:

  1. Is the user measuring Android or Desktop (Linux/macOS/Windows)?
    • Yes: Run flutter build <platform> --analyze-size. Proceed to DevTools analysis.
    • No: Proceed to step 2.
  2. Is the user measuring iOS?
    • Yes: Run flutter build ipa --export-method development and generate an Xcode App Thinning Size Report for accurate download estimates.
  3. Is the user analyzing the breakdown of components?
    • Yes: Launch dart devtools, open the App Size Tool, and upload the generated *-code-size-analysis_*.json file.
  4. Is the user applying size reduction strategies?
    • Yes: Apply --split-debug-info, compress assets, and implement Platform checks for aggressive tree-shaking.

Instructions

  1. Determine Target Platform and Baseline STOP AND ASK THE USER: "Which platform (apk, appbundle, ios, linux, macos, windows) are you targeting for size optimization, and do you have a specific size reduction goal?"

  2. Generate Size Analysis File Execute the Flutter build command with the --analyze-size flag to compile Dart with code size usage recording.

    # Replace <platform> with apk, appbundle, ios, linux, macos, or windows
    flutter build <platform> --analyze-size
    

    Note: This generates a *-code-size-analysis_*.json file in the build/ directory and prints a high-level summary to the terminal.

  3. Generate iOS App Size Report (iOS Only) If targeting iOS, the .app file generated by --analyze-size only evaluates relative size. For an accurate end-user download estimate, generate an Xcode App Size Report.

    flutter build ipa --export-method development
    
    • Follow up by instructing the user to:
      1. Open the archive (build/ios/archive/*.xcarchive) in Xcode.
      2. Click Distribute App -> Development.
      3. In App Thinning, select "all compatible device variants".
      4. Select Strip Swift symbols.
      5. Export the IPA and review the App Thinning Size Report.txt.
  4. Analyze Components in DevTools Launch DevTools to inspect the JSON analysis file.

    dart devtools
    
    • Instruct the user to open the "App Size Tool" in the DevTools browser UI and upload the *-code-size-analysis_*.json file.
    • Use the Treemap or Dominator Tree to identify large packages, libraries, or assets.
  5. Implement Size Reduction Strategies Apply the following strategies to the build process and codebase:

    Strategy A: Split Debug Info and Obfuscate Extract debug symbols from the compiled binary to reduce the final artifact size.

    flutter build appbundle --obfuscate --split-debug-info=build/app/outputs/symbols/
    

    Strategy B: Platform-Specific Tree Shaking Use dart:io Platform checks to ensure the Dart AOT compiler removes unreachable code for the target platform.

    import 'dart:io';
    
    void initializePlatformSpecificFeatures() {
      if (Platform.isWindows) {
        // Windows-specific imports and logic
        // The AOT compiler will strip this out when building for Android/iOS
        _initWindowsFeatures();
      } else if (Platform.isAndroid) {
        _initAndroidFeatures();
      }
    }
    
  6. Validate and Fix After applying reduction strategies, regenerate the size analysis file.

    flutter build <platform> --analyze-size
    

    STOP AND ASK THE USER: "Please upload the new *-code-size-analysis_*.json file to DevTools and compare it with the original using the 'Diff' tab. Did the app size decrease to meet your requirements?"

    • Error State: If the size did not decrease, verify that --split-debug-info was applied correctly and that large assets (PNG/JPEG) have been compressed or removed.

Constraints

  • NEVER use debug builds (flutter run or standard IDE play buttons) to measure app size. They contain debugging overhead and are not representative of production sizes.
  • NEVER assume the upload package size (e.g., a universal APK or AAB) is the exact download size for end-users. App stores filter native libraries and asset densities.
  • ALWAYS provide a valid directory path when using the --split-debug-info flag.
  • DO NOT rely solely on the iOS .app file size; always use the Xcode App Thinning Size Report for accurate iOS download size estimates.
  • ALWAYS ensure that Platform checks use dart:io constants directly so the AOT compiler can accurately perform tree-shaking.

Version History

  • c1dc382 Current 2026-08-20 13:17

Same Skill Collection

.claude/skills/asset-image-subsystem/SKILL.md
.claude/skills/baoyu-danger-x-to-markdown/SKILL.md
.claude/skills/flutter-accessibility/SKILL.md
.claude/skills/flutter-architecture/SKILL.md
.claude/skills/flutter-concurrency/SKILL.md
.claude/skills/flutter-environment-setup-linux/SKILL.md
.claude/skills/flutter-environment-setup-macos/SKILL.md
.claude/skills/flutter-environment-setup-windows/SKILL.md
.claude/skills/flutter-http-and-json/SKILL.md
.claude/skills/flutter-layout/SKILL.md
.claude/skills/flutter-localization/SKILL.md
.claude/skills/flutter-native-interop/SKILL.md
.claude/skills/flutter-plugins/SKILL.md
.claude/skills/flutter-routing-and-navigation/SKILL.md
.claude/skills/flutter-testing/SKILL.md
.claude/skills/flutter-theming/SKILL.md
.claude/skills/headless-scraping/SKILL.md
.claude/skills/moai-lang-flutter/SKILL.md
.claude/skills/mobile-ai-chat-client/SKILL.md
.claude/skills/mobile-note-sync-architecture/SKILL.md
.claude/skills/note-resource-catalog-reliability/SKILL.md
.claude/skills/note-resource-event-driven-architecture/SKILL.md
.claude/skills/pocketmind-context-architecture/SKILL.md
.claude/skills/skill-creator/SKILL.md
backend/.claude/skills/code-reviewer/SKILL.md
.claude/skills/flutter-animation/SKILL.md
.claude/skills/flutter-caching/SKILL.md
.claude/skills/flutter-databases/SKILL.md
.claude/skills/flutter-form/SKILL.md
.claude/skills/flutter-home-screen-widget/SKILL.md
.claude/skills/flutter-performance/SKILL.md
.claude/skills/flutter-platform-views/SKILL.md
.claude/skills/flutter-state-management/SKILL.md

Metadata

Files
0
Version
c1dc382
Hash
f5394d73
Indexed
2026-08-20 13:17

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 08:47
浙ICP备14020137号-1 $방문자$