Version Checker Popup is used to prompt user for website reloading with clearing cached data to apply a new version of the site.
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
- ifinstantCheck
is set totrue
, 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.
<script>
function hardReload() {
setTimeout(function () {
window.location.reload(true);
}, 100);
}
</script>
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"
Add examples here
Feel free to post a feature requests or report a bug here.