AgentSkillsCN

flutter-terminal-cheat-sheet

本文为您精心整理了一系列适用于 Web 开发、包创建、故障排查、测试等场景的 Flutter 命令与脚本,助您高效优化 Flutter 开发流程。

SKILL.md
--- frontmatter
name: flutter-terminal-cheat-sheet
description: This post provides a handy collection of Flutter commands and scripts for web development, package creation, troubleshooting, testing, and more, streamlining your Flutter workflow.
metadata:
  url: https://rodydavis.com/posts/flutter-cheat-sheet
  last_modified: Tue, 03 Feb 2026 20:04:23 GMT

Flutter Terminal Cheat Sheet

Run Flutter web with SKIA

code
flutter run -d web --release --dart-define=FLUTTER_WEB_USE_SKIA=true

Run Flutter web with Canvas Kit

code
flutter run -d chrome --release --dart-define=FLUTTER_WEB_USE_EXPERIMENTAL_CANVAS_TEXT=true

Build your Flutter web app to Github Pages to the docs folder

code
flutter build web && rm -rf ./docs && mkdir ./docs && cp -a ./build/web/. ./docs/

Clean rebuild CocoaPods

code
cd ios && pod deintegrate && pod cache clean —all && pod install && cd ..

Sometimes with firebase you need to run: pod update Firebase

Create Dart package with Example

code
flutter create -t plugin . && flutter create -i swift -a kotlin --androidx example

Watch Build Files

code
flutter packages pub run build_runner watch  -—delete-conflicting-outputs

Generate Build Files

code
flutter packages pub run build_runner build  -—delete-conflicting-outputs

Build Bug Report

code
flutter run —bug-report

Flutter generate test coverage

code
flutter test --coverage && genhtml -o coverage coverage/lcov.info

Rebuild Flutter Cache

code
flutter pub pub cache repair

Clean every flutter project

code
find . -name "pubspec.yaml" -exec $SHELL -c '
    echo "Done. Cleaning all projects."
    for i in "$@" ; do
        DIR=$(dirname "${i}")
        echo "Cleaning ${DIR}..."
        (cd "$DIR" && flutter clean >/dev/null 2>&1)
    done
    echo "DONE!"
' {} +

Conditional Export/Import

code
export 'unsupported.dart'
    if (dart.library.html) 'web.dart'
    if (dart.library.io) 'mobile.dart';

Kill Dart Running

code
killall -9 dart

Flutter scripts 

Add all the scripts to your pubspec.yaml with flutter_scripts.