Hope you’re coding well.
I am building flutter web app and need to be able to run it on local network with canvaskit build.
A web request is sent to gstatic on initialization of web app from client side.
When not connected to internet the response fails to fetch canvaskit.js
How can I make my app get this file from local server so the app can run without the need of internet.
I have added the following lines to my index.html
file and still requests for canvaskit.js
:
<script>
window.flutterConfiguration = {
canvasKitBaseUrl: "/canvaskit/"
};
</script>
<script>
window.addEventListener('load', function (ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function (engineInitializer) {
let config = {
canvasKitVariant: "full",
};
engineInitializer.initializeEngine(config).then(function (appRunner) {
appRunner.runApp();
});
}
});
});
</script>
and I have tried building web app with the following commands:
flutter build web --web-renderer canvaskit
flutter build web --dart-define=FLUTTER_WEB_USE_SKIA=true --web-renderer canvaskit
flutter build web --dart-define=FLUTTER_WEB_CANVASKIT_URL=./canvaskit.js --dart-define=FLUTTER_WEB_USE_SKIA=true --web-renderer canvaskit
my flutter doctor is:
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.19044.4046], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.34)
X The current Visual Studio installation is incomplete.
Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.
[√] Android Studio (version 2023.1)
[√] VS Code (version 1.88.1)
[√] Connected device (4 available)
[!] Network resources
X A network error occurred while checking "https://maven.google.com/": The semaphore timeout period has expired.
! Doctor found issues in 3 categories.
Can you guys help please. Thanks in advance.