Skip to content

[Proposal] Include build number in pubspec.yaml version when using flutter create #165325

@felangel

Description

@felangel

Use case

When a new project is created via flutter create -e example, the generated pubspec.yaml is:

name: example
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.0

environment:
  sdk: ^3.7.2

dependencies:
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^5.0.0

flutter:
  uses-material-design: true

Since the version does not specify a build number, if the user does not change the version and tries to build a release artifact (via flutter build), the generated artifact's build number will be inconsistent due to differences in platform behavior. For example, on iOS and macOS, the build_number will be 0.1.0 so the full version ends up being 0.1.0+0.1.0 whereas on Android the build number will be 1, so the full version ends up being 0.1.0+1.

This is problematic because creating a new app and subsequently releasing on multiple platforms should generate artifacts with a consistent release version in my opinion.

I believe at one point, newly created apps did include a build number but at some point it was removed (not sure why 🤷 ).

Flutter Version

flutter --version
Flutter 3.29.2 • channel stable • [email protected]:flutter/flutter.git
Framework • revision c236373904 (4 days ago) • 2025-03-13 16:17:06 -0400
Engine • revision 18b71d647a
Tools • Dart 3.7.2 • DevTools 2.42.3

Proposal

I propose adjusting the flutter create template to include a build number automatically:

name: example
description: "A new Flutter project."
publish_to: 'none'
- version: 0.1.0
+ version: 0.1.0+1

environment:
  sdk: ^3.7.2

dependencies:
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^5.0.0

flutter:
  uses-material-design: true

Happy to open a pull request if folks are in agreement, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Fluttergood first issueRelatively approachable for first-time contributorsteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions