1

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>
djalmafreestyler
  • 1,703
  • 5
  • 21
  • 42

3 Answers3

4

try running

  • flutter clean flutter pub get

  • flutter build web then firebase deploy

Aristidios
  • 1,921
  • 2
  • 13
  • 24
3

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"
          }
        ]
      }

    ]
  }


}
djalmafreestyler
  • 1,703
  • 5
  • 21
  • 42
0
  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
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 06 '21 at 01:50