Flutter Build
Flutter allows you to build cross-platform mobile apps from a single codebase. This recipe demonstrates how to build iOS and Android apps using Flutter, including dependency installation and build compilation.
Flutter iOS Build YAML
Section titled “Flutter iOS Build YAML”name: Flutter iOS Buildplatform: flutter
environment: flutter: "3.24.0"
triggers: - push - pull_request
steps: - name: Install dependencies run: fvm flutter pub get
- name: Build iOS run: fvm flutter build iosFlutter Cross-Platform Build
Section titled “Flutter Cross-Platform Build”name: Flutter Mobile Buildplatform: flutter
environment: flutter: "3.24.0"
triggers: - push - pull_request
steps: - name: Install dependencies run: fvm flutter pub get
- name: Build Android run: fvm flutter build apk
- name: Build iOS run: fvm flutter build iosBuild Workflow
Section titled “Build Workflow”The typical Flutter build workflow includes:
- Dependency Installation:
fvm flutter pub getresolves all Pub dependencies specified inpubspec.yaml - iOS Build:
fvm flutter build iosgenerates an iOS app bundle - Android Build:
fvm flutter build apkgenerates an Android APK
Key Points
Section titled “Key Points”- pubspec.yaml: Your Flutter project’s manifest file, similar to
Package.swiftfor native Swift orpackage.jsonfor Node.js - pub get: Downloads and installs all dependencies from pub.dev
- Platform-specific builds: Flutter can generate both iOS and Android builds from the same source code
- .fvmrc file (optional): Commit this at your repository root to pin the Flutter SDK version; if you set
environment.flutter: fvm, the agent will read the version from your.fvmrcfile
Collecting Flutter Build Artifacts
Section titled “Collecting Flutter Build Artifacts”You can collect build outputs from your Flutter builds:
name: Flutter Build with Artifactsplatform: flutter
environment: flutter: "3.24.0"
triggers: - push
steps: - name: Install dependencies run: fvm flutter pub get
- name: Build iOS run: fvm flutter build ios
- name: Build Android run: fvm flutter build apk
artifacts: - build/ios/iphoneos/**/*.app - build/ios/archive/**/*.xcarchive - build/app/outputs/**/*.apk