Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Latest commit

 

History

History
86 lines (54 loc) · 2.66 KB

README.md

File metadata and controls

86 lines (54 loc) · 2.66 KB

version_checker

Build Pub GitHub GitHub stars

Version Checker Popup is used to prompt user for website reloading with clearing cached data to apply a new version of the site.

THIS PLUGIN IS DISCONTINUED

Getting Started

IMPORTANT! main.dart.js script must be the first script in body tag!

To start using this popup VersionChecker.initialize method should be called only once, for instance within constructor of App class within main.dart file.

Via VersionChecker.initialize method could be set delay for checking version:

  • timerDelay - periodical delay.
  • instantDelay - if instantCheck is set to true, then after this delay version will be checked instantly.

Also, for localization purposes this method has following arguments:

  • newVersionAvailableText - title of popup.
  • applyText - complete action button title.

If debugOutput argument is set to true, then extra info will be printed into console.

In index.html file add following code between head and body tags:

<script>
function hardReload() {
    setTimeout(function () {
        window.location.reload(true);
    }, 100);
}
</script>

Before deploying website, you should update build script as follows:

Linux:

#!/bin/bash

VERSION=$(sed -n -e 's/^version: \([0-9]*\.[0-9]*\.[0-9]*\)\(+[0-9]*\)*/\1/p' pubspec.yaml)

echo "App Version: ${VERSION}"

flutter build web

echo "Updating app version..."

sed -i "s/src=\"main.dart.js\"/src=\"main.dart.js?v=${VERSION}\"/g" build/web/index.html
sed -i "s/\"app_version\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"app_version\": \"${VERSION}\"/g" build/web/assets/packages/version_checker/assets/env.json

echo "App version updated"

macOS:

#!/bin/bash

VERSION=$(sed -n -e 's/^version: \([0-9]*\.[0-9]*\.[0-9]*\)\(+[0-9]*\)*/\1/p' pubspec.yaml)

echo "App Version: ${VERSION}"

flutter build web

echo "Updating app version..."

sed -i '' "s/src=\"main.dart.js\"/src=\"main.dart.js?v=${VERSION}\"/g" build/web/index.html
sed -i '' "s/\"app_version\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"app_version\": \"${VERSION}\"/g" build/web/assets/packages/version_checker/assets/env.json

echo "App version updated"

Examples

Add examples here

Feature requests and Bug reports

Feel free to post a feature requests or report a bug here.