This template provides a lightweight Flutter project container with centralized configuration and shared ADB infrastructure support.
FlutterBench is moving to the layered workBenches model (workbench-base → dev-bench-base → flutter-bench). Any monolithic .devcontainer/Dockerfile in this template is legacy and should be treated as deprecated.
Key Principle: The .env file is the ONLY place for project and user-specific configuration.
- 🚫 Template files are NEVER modified - All
.devcontainer,.vscode, Docker files remain untouched - ✅ All customization via
.envfile - Container names, user settings, versions, ports - ✅ Perfect reusability - Same template works for unlimited projects
- ✅ Conflict-free updates - Template improvements never break your settings
- ✅ Configurable container naming - Control both app and service container names
# .env file:
PROJECT_NAME=dartwing
APP_CONTAINER_SUFFIX=app
SERVICE_CONTAINER_SUFFIX=gateway
# Results in containers:
# - dartwing-app (Flutter container)
# - dartwing-gateway (Service container)This container is designed for individual Flutter projects and follows the principle:
- FlutterBench = Heavy development workbench with all tools (~2GB+, 10+ minute build)
- Project Containers = Lightweight debugging/running environment (~500MB, 2-3 minute build)
Use this for: Debugging, testing, light edits, running your app
Use FlutterBench for: Heavy development, code generation, complex builds, polyglot work
-
Create your Flutter project:
cd Dartwingers # or your desired project group flutter create your_project_name cd your_project_name
-
Copy template files:
cp -r ../../DevBench/FlutterBench/templates/flutter-devcontainer-template/.devcontainer . cp -r ../../DevBench/FlutterBench/templates/flutter-devcontainer-template/.vscode . cp -r ../../DevBench/FlutterBench/templates/flutter-devcontainer-template/scripts . cp ../../DevBench/FlutterBench/templates/flutter-devcontainer-template/.env.example . cp ../../DevBench/FlutterBench/templates/flutter-devcontainer-template/.gitignore .
3. **Set up environment configuration**:
```bash
cp .env.example .env
# Edit .env and set PROJECT_NAME, USER_UID, USER_GID, etc.
# Run 'id' to check your UID and GID
-
Validate configuration (required for manual setup):
./scripts/manual-setup-project.sh
-
Open in VS Code:
code . -
Reopen in container when prompted by VS Code
Use the provided script:
cd Bench/DevBench/FlutterBench/scripts
./new-flutter-project.sh your_project_name ../../Dartwingers- ✅ Automatic ADB infrastructure startup via
initializeCommand - ✅ Flutter pub get and precache on container creation
- ✅ Flutter doctor and device check on startup
- ✅ VS Code extensions for Flutter/Dart development
- ✅ Optimized settings for Flutter development
tasks.json: Pre-configured tasks for:- 🔌 ADB connection management
- 🩺 Flutter doctor, clean, test, analyze
- 📱 Flutter run (debug/release)
- 🔧 Pub get/upgrade
launch.json: Debug configurations for Flutter apps and testssettings.json: Optimized Flutter development settings
docker-compose.yml:- Environment-driven configuration using
.envfile - Connects to shared
${NETWORK_NAME}network (default: dartnet) - Configured for shared ADB server with customizable host/port
- Persistent pub and gradle caches per project
- Resource limits configurable via
.env - Port mappings for hot reload and DevTools
- Environment-driven configuration using
Dockerfile(legacy, deprecated):- Monolithic build instructions (kept for reference only)
- Prefer layered images for new work
.env.example: Template with all available configuration options.env: Your project-specific configuration (auto-created, not in git)- Key variables:
PROJECT_NAME: Container and volume namesUSER_UID/USER_GID: Match your host user for file permissionsFLUTTER_VERSION: Specify Flutter SDK versionCONTAINER_MEMORY/CONTAINER_CPUS: Resource limitsADB_SERVER_HOST/ADB_SERVER_PORT: Shared ADB configuration
This template uses environment variables via .env files for flexible, per-project configuration.
# 1. Copy template
cp .env.example .env
# 2. Edit key variables
# PROJECT_NAME=myproject
# USER_UID=1000 # Run 'id -u' to check
# USER_GID=1000 # Run 'id -g' to check
# 3. Validate (required for manual setup)
./scripts/manual-setup-project.shPROJECT_NAME: Base name for containers and volumesAPP_CONTAINER_SUFFIX: Suffix for app container (default:app) → Results inPROJECT_NAME-appSERVICE_CONTAINER_SUFFIX: Suffix for service container (default:service,gatewayfor Dartwing) → Results inPROJECT_NAME-serviceCOMPOSE_PROJECT_NAME: Docker Compose stack name (default:flutter,dartwingersfor Dartwingers projects)NETWORK_NAME: Docker network (default:dartnet)
USER_NAME: Username in container (default:vscode)USER_UID: User ID - should match your host UID (id -u)USER_GID: Group ID - should match your host GID (id -g)
FLUTTER_VERSION: SDK version (e.g.,3.24.0,3.19.6,stable)ANDROID_HOME: Android SDK path in container
CONTAINER_MEMORY: RAM limit (e.g.,4g,8g)CONTAINER_CPUS: CPU limit (e.g.,2,4)
HOT_RELOAD_PORT: Flutter hot reload (default:8080)DEVTOOLS_PORT: Flutter DevTools (default:9100)
ADB_SERVER_HOST: Shared ADB server hostname (default:shared-adb-server)ADB_SERVER_PORT: ADB port (default:5037)
✅ DO:
- Copy
.env.exampleto.envfor each project - Set
PROJECT_NAMEto something unique - Match
USER_UID/USER_GIDto your host user - Keep
.env.examplein git as template
❌ DON'T:
- Commit
.envto git (contains user-specific config) - Use spaces around
=(e.g.,KEY = value) - Use quotes around values (e.g.,
KEY="value") - Leave
PROJECT_NAMEas defaultmyproject
Use the included validation script to check your configuration:
./scripts/manual-setup-project.shThis script will:
- ✅ Check if
.envexists (creates from.env.exampleif missing) - ✅ Validate all required variables are set
- ✅ Check variable formats (PROJECT_NAME, UID/GID)
- ✅ Verify Docker environment
- ✅ Test Docker Compose configuration
- ✅ Check infrastructure path
📖 For detailed script usage, see scripts/README.md
The template assumes your project structure follows this pattern:
projects/
├── infrastructure/ ← Shared ADB infrastructure
├── Dartwingers/ ← Flutter projects (2 levels deep)
│ └── your_project/ ← Your project here
├── DavinciDesigner/ ← Multi-tech projects (2 levels deep)
│ └── flutter-app/ ← Your project here
└── SomeOther/ ← Other project groups
└── nested/ ← 3 levels deep = '../../../infrastructure'
└── flutter-app/
Path Adjustment: If your project is at a different depth, update the path in .devcontainer/devcontainer.json:
- 3 levels deep:
../../../infrastructure/mobile/android/adb/scripts/start-adb-if-needed.sh - 4 levels deep:
../../../../infrastructure/mobile/android/adb/scripts/start-adb-if-needed.sh
Template files use environment variable substitution - no manual editing required:
devcontainer.jsonuses"name": "${localEnv:PROJECT_NAME}"to read from.envdocker-compose.ymluses${PROJECT_NAME}-${APP_CONTAINER_SUFFIX}for container names- All configuration comes from your
.envfile automatically
- ✅ Shared ADB server starts automatically when container opens
- ✅ No port conflicts between multiple Flutter projects
- ✅ Connects to Android emulators on Windows host
- ✅ Flutter SDK 3.24.0 (stable channel only)
- ✅ Minimal Android SDK (platform-tools for ADB debugging)
- ✅ Java 17 JDK (OpenJDK)
- ✅ Essential tools only: git, curl, nano, jq, tree, zsh, Oh My Zsh
- ✅ ImageMagick (with full comparison support, PDF/Ghostscript, and fonts)
- ✅ Pre-configured VS Code extensions for Flutter/Dart
- ✅ Optimized for project debugging - not heavy development
- ✅ Fast container startup (~2-3 minutes vs 10+ for FlutterBench)
- ✅ 14 pre-configured tasks for common Flutter operations
- ✅ Debug configurations for app and test debugging
- ✅ Auto-format on save
- ✅ Import organization
- ✅ Flutter-specific file associations
- ✅ Persistent pub cache volume (faster dependency downloads)
- ✅ Persistent gradle cache volume (faster Android builds)
- ✅ Flutter precache during container creation
- ✅ Optimized Dockerfile layers
-
Prerequisites:
- Shared ADB infrastructure must be set up at
projects/infrastructure/mobile/android/adb/ - Docker Desktop running
- VS Code with Dev Containers extension
- Shared ADB infrastructure must be set up at
-
First Time Setup:
- Use Option A (manual) or Option B (script) above
- Wait for container build (first time takes ~5-10 minutes)
- Container will automatically run
flutter doctorandadb devices
-
Development Workflow:
- Start Android emulator on Windows host
- Open project in VS Code
- Container auto-starts with ADB connectivity
- Use Command Palette → Tasks to run Flutter commands
- Use F5 to debug, or Run/Debug buttons in VS Code
The container includes ImageMagick with full support for image comparison operations, ideal for visual regression testing and screenshot comparisons.
# Compare two images and generate a diff
magick compare -metric RMSE baseline.png candidate.png diff.png
# Compare with absolute error count
magick compare -metric AE baseline.png candidate.png diff.png
# Get normalized cross-correlation (similarity score)
magick compare -metric NCC baseline.png candidate.png null:
# Show version and available delegates
magick identify -version- ✅ ImageMagick CLI tools (
magick,compare,identify,convert) - ✅ MagickCore & MagickWand libraries for language bindings
- ✅ Ghostscript for PDF comparison and rasterization
- ✅ DejaVu fonts to prevent missing-glyph errors in text overlays
- Store comparison outputs in
/workspace/tmpor similar to persist results - Use metrics:
RMSE(root mean square error),AE(absolute error),NCC(normalized cross-correlation) - Validate installation runs automatically on container creation via
postCreateCommand
# 1. Take baseline screenshots
flutter test --update-goldens
# 2. Make UI changes
# 3. Generate new screenshots
flutter test
# 4. Compare with ImageMagick
mkdir -p tmp
magick compare -metric RMSE test/goldens/widget_old.png test/goldens/widget_new.png tmp/diff.png# Clean and rebuild
docker-compose build --no-cache# Inside container terminal
adb devices
# Should show connected emulator
# Or use VS Code task: "🔌 Check ADB Connection"# From your project directory, verify path
ls -la ../../infrastructure/mobile/android/adb/scripts/start-adb-if-needed.sh
# Should show the script file# Inside container terminal
flutter doctor -v
# Or use VS Code task: "🩺 Flutter Doctor"This template is maintained in:
- Source:
Bench/DevBench/FlutterBench/templates/flutter-devcontainer-template/ - Script:
Bench/DevBench/FlutterBench/scripts/new-flutter-project.sh
To update all projects with template changes, manually copy updated files or re-run the script.
Happy Flutter Development! 🎯