When publishing Flutter apps to Google Play or the App Store, the cleanest and most reliable approach is to centralize all version management in pubspec.yaml.
This ensures consistent versioning across both platforms and avoids environment-dependent issues.
Flutter allows you to define both versionName and versionCode in one line:
version: 1.0.0+4
1.0.0 → versionName (Android) / CFBundleShortVersionString (iOS)+4 → versionCode (Android) / CFBundleVersion (iOS)The versionCode must always increase.
Example: +3 → +4 → +5
The versionName can change freely, but versionCode must be strictly incremental for Google Play.
local.properties is an environment-specific file and should never be used for versioning.
sdk.dir=/Users/Username/Library/Android/sdk
flutter.sdk=/Users/Username/Developer/flutter
# ↓これらは削除/未記載にする(Flutterがpubspec.yamlから拾うため不要)
# flutter.buildMode=release
# flutter.versionName=1.0.0
# flutter.versionCode=3
local.properties should not be committed to Git and should contain only SDK paths.
Flutter’s standard templates already reference flutter.versionCode and flutter.versionName.
defaultConfig {
applicationId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode // ← Flutterがpubspecから埋める
versionName = flutter.versionName
}
The recommended builds are simple:
flutter build appbundle --release
This automatically uses versions defined in pubspec.yaml.
This should only be used for temporary overrides.
flutter build appbundle --release --build-name 1.0.1 --build-number 4
Before every release to Google Play or App Store:
pubspec.yamlversion: 1.0.0+N # Increase N by +1
flutter clean
flutter pub get
flutter build appbundle --release
| Item | Best Practice |
|---|---|
| Version management location | pubspec.yaml (single source of truth) |
| versionCode | Increase every release (required by Google Play) |
| local.properties | Do NOT use for versioning |
| Build command | flutter build without extra flags |