djalmafreestyler
djalmafreestyler

Reputation: 1909

How to update version of a Flutter Web deployed in Firebase Hosting

In older versions of Flutter, the web/index.html file was built with a script inside that calls main.dart.js but this script was removed in newer versions and I used to add a "version" attribute to specify the version, how to update the version of my flutter web deployed on Firebase Hosting? Is there any other way to that now?

/// Original
<script src="main.dart.js" type="application/javascript"></script>

/// Modified
<script src="main.dart.js?version=10" type="application/javascript"></script>

Upvotes: 1

Views: 4789

Answers (3)

Aristidios
Aristidios

Reputation: 2321

try running

  • flutter clean flutter pub get

  • flutter build web then firebase deploy

Upvotes: 4

Mateus F&#233;lix
Mateus F&#233;lix

Reputation: 37

  1. Adjust your project and save the changes;
  2. Change the version on pubspec.yaml (from 1.0.0+1 to 1.0.1+1 for example);
  3. Run flutter build web
  4. Run firebase deploy

Upvotes: 1

djalmafreestyler
djalmafreestyler

Reputation: 1909

I ended up adding this script manually inside the body tag and disabled cache in firebase.json file.

index.html

<script src="main.dart.js?version=10" type="application/javascript"></script>

firebase.json

{
  "hosting": {
    "public": "build/web",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],

    "headers": [

      {
        "source": "**",
        "headers": [
          {
            "key": "Cache-Control",
            "value": "no-cache"
          }
        ]
      }

    ]
  }


}

Upvotes: 3

Related Questions