Flutter web加载缓慢原因:Flutter
使用的一个渲染引擎 Canvaskit
下载太慢导致的.
解决方法:
Canvaskit
是一个 js
框架,Flutter
定义默认是从 https://unpkg.com 去加载的,在国内最好是改变这个地址,让它通过镜像地址去加载.
编译发布:
flutter build web --dart-define=FLUTTER_WEB_CANVASKIT_URL=https://cdn.jsdelivr.net/npm/canvaskit-wasm@0.24.0/bin/
运行调试:
flutter run -d chrome --dart-define=FLUTTER_WEB_CANVASKIT_URL=https://cdn.jsdelivr.net/npm/canvaskit-wasm@0.24.0/bin/ --release
其他的镜像源:
知乎[未知]
1
|
--dart-define=FLUTTER_WEB_CANVASKIT_URL=https://unpkg.zhimg.com/canvaskit-wasm@0.24.0/bin/
|
饿了么[可用速度快]
1
|
--dart-define=FLUTTER_WEB_CANVASKIT_URL=https://npm.elemecdn.com/canvaskit-wasm@0.24.0/bin/
|
jsDelivr[可用速度慢]
1
|
--dart-define=FLUTTER_WEB_CANVASKIT_URL=https://cdn.jsdelivr.net/npm/canvaskit-wasm@0.24.0/bin/
|