flutter web loading canvaskit locally
03:25 28 Apr 2024

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:

  
 

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
flutter build web --base-href "/" --no-web-resources-cdn --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.

I managed to load canvaskit from local files but the following syntax error occurs in canvaskit.js 97:504 the following line consists of:

var gb=0,ib=0,jb="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,kb=(a,b,c)=>{var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16

Can you guys help please. Thanks in advance.

flutter canvaskit