flutter Web打包

flutter build web

flutter build web --web-renderer canvaskit

这将生成包括资源的应用程序,并将文件放入项目的 /build/web 目录中。

一般的应用程序的 release 版本具有以下结构:

content_copy

/build/web

assets

AssetManifest.json

FontManifest.json

NOTICES

fonts

MaterialIcons-Regular.ttf

index.html

main.dart.js

main.dart.js.map

启动 Web 服务器(例如,python -m SimpleHTTPServer 8000,或使用 dhttpd package),然后打开 /build/web 目录。在浏览器中访问 localhost:8000(前文用 Python 启动的服务器)以查看应用程序的 release 版本。

经过测试,上面三种方式都可以打包web版本, 其中第一种是针对移动端的打包方式, 第二种是一般的打包方式, 第三种是针对pc端的打包方式.

那这3种方式打包出来,运行起来有什么不同呢

flutter build web --web-renderer html 打开速度最快,兼容性好(是指ie,chrome,safari等浏览器兼容)

你可能感兴趣的:(程序员,flutter,前端)