Flutter Build Release
# Flutter Build and Release
This section will introduce how to package and release a Flutter application to various platforms.
* * *
## Build Preparation
Before releasing, ensure that your application is properly configured.
### pubspec.yaml Configuration
## Example: Publishing Configuration
# Application Information
name: my_app
description: "My Flutter Application"
version: 1.0.0+1# Version Number (Important!)
# Application Icon
flutter:
uses-material-design: true
# Generate icons using flutter pub run flutter_launcher_icons
### Android Configuration
Modify the application configuration in android/app/build.gradle:
## Example: Android Configuration
// android/app/build.gradle
android {
namespace "com.example.myapp"
compileSdk = 34
defaultConfig {
applicationId "com.example.myapp" // Application ID
minSdk = 21 // Minimum Android version
targetSdk = 34 // Target version
versionCode 1 // Version code (increment with each release)
versionName "1.0.0" // Version name
}
signingConfigs {
release {
// Release signing configuration
storeFile file("key.jks")
storePassword "password"
keyAlias "alias"
keyPassword "key password"
}
}
}
* * *
## Android Build
### Building APK
# Debug APK $ flutter build apk --debug # Release APK $ flutter build apk --release # Signed (requires signingConfigs configuration) $ flutter build apk --release --target-platform android-arm64
### Building App Bundle
# Build App Bundle (recommended for Google Play) $ flutter build appbundle --release
* * *
## iOS Build
### Preparations
* Install Xcode
* Configure Apple Developer account
* Create App ID and certificates
### Command Line Build
# Simulator version $ flutter build ios --simulator --no-codesign # Release version (requires signing) $ flutter build ipa --release
### Using Xcode to Build
1. Open the .xcworkspace file in the ios/ directory
2. Select the target device and Signing configuration
3. Click Product > Archive
* * *
## Web Build
# Build Web version $ flutter build web --release # Output directory: build/web/
### Web Configuration
Configure the application in web/index.html:
## Example: Web Configuration
My Application
* * *
## Desktop Application Build
# Windows $ flutter build windows --release # macOS $ flutter build macos --release # Linux $ flutter build linux --release
> Be sure to test your release version before publishing; debug builds may contain additional debugging information.
YouTip