Skip to content

"Static" versioning in flutter web #149725

Description

@RoarGronmo

Use case

This underlying problem for my suggestion is in theese links:
#104509
fluttercommunity/plus_plugins#2675

When working with scenarios in Flutter web where we need to address the current version which is cached in the users browser, we do not have any easy way to get that version. The tool package_info_plus may give is a version, but that one is bound to the /version.json on the web site's server, not the actual version of the cached code on the users browser.

Proposal

It would have been VERY convenient to have access to the pubspec.yaml version string during build, so you could address that version as "staticVersion" or " cachedVersion" during run-time. This would make version-checking very easy, and you could address proper ways to refresh your page, either automatically or suggested actions for the user, when the page version on server changes.

My suggestion is to have a global variable i.e. like String cachedVersion and Int cachedBuild int the form "x.y.z+build" and build, which is populated during build time from the values which are presended in the version parameter in pubspec.yaml.

Theese values should be incorporated in the code, so it shouldn't be taken from \version.json in the same way as package_info_plus does, which now follows the version presented on the server, not currently cached in the browser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: proposalA detailed proposal for a change to Flutterdependency: dartDart team may need to help usplatform-webWeb applications specificallyr: invalidIssue is closed as not validteam-webOwned by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions