一. 打包问题
1. 提示依赖
webdev could not run for this project.
This version of webdev does not support the `build_daemon` protocol used by your version of `build_runner`.
Please add a dev dependency on `build_daemon` with constraint: >=1.0.0 <2.0.0
在pubspec.yaml下dev_dependencies中添加依赖:
dev_dependencies:
build_daemon: ^1.0.0
二. VSCode 按F5调试运行不起来
1. 提示版本低
webdev could not run for this project.
This version of webdev does not support the `build_daemon` protocol used by your version of `build_runner`.
A newer version of webdev is available which supports your version of the `build_daemon`. Please update.
查看了版本都没有问题,最后认为是VSCode使用的webdev版本问题(理论上用的和电脑一样才对),暂时使用命令方式 webdev serve来运行,过了几天VSCode提示更新webdev版本,点击更新后,自动就好了
2. 提示找不到main.dart
VSCode提示:
Error: Error when reading 'bin/main.dart': No such file or directory
看到.vscode包下的配置了bin/main.dart,也是奇怪
"version": "0.2.0",
"configurations": [
{
"name": "Dart",
"program": "bin/main.dart",
"request": "launch",
"type": "dart"
}
]
处理:将其修改为 web/main.dart
3. webdev could not run for this project.
更新flutter和webdev后,出现运行项目运行不起来,flutter版本1.5.4-hotfix.2 ,wevdev版本2.1.0
- 提示:
运行项目提示说pubspect.yaml找不到:
Could not find a file named "pubspec.yaml" in "/Users/xxxx/.pub-cache/git/flutter_web-1ed4317aa91038ba99531037ce00c04672c4bee1/packages/flutter_web_ui"
然后我干脆删除了这个flutter_web-的文件夹,然后重新deactivate了 wevdev
flutter pub global deactivate webdev
再重新执行
flutter pub global activate webdev
再进行项目的执行,问题又来了:
webdev could not run for this project.
Could not find a file named "pubspec.yaml" in "/Users/shixin/.pub-cache/hosted/pub.flutter-io.cn/protobuf-0.13.12".
接下来我又修改了项目的pubspec.yaml文件,
build_daemon: ^1.0.0
to
build_daemon: ^1.1.0
再同步一下,pub get后,运行项目,项目能运行了,新问题来了,一直处于launching状态,很是尴尬啊!
- 再尝试打包工程:
webdev build
看到控制台有输出:
[WARNING]build_web_compilers:entrypoint on web/main.dart: Skipping compiling flutter_web_demo|web/main.dart with dart2js because some of its
transitive libraries have sdk dependencies that not supported on this platform:
dio|lib/src/dio.dart
dio|lib/src/transformer.dart
dio|lib/src/interceptors/cookie_mgr.dart
dio|lib/src/response.dart
dio|lib/src/dio_http_headers.dart
dio|lib/src/upload_file_info.dart
dio|lib/src/options.dart
dio|lib/src/form_data.dart
dio|lib/src/adapter.dart
cookie_jar|lib/src/persist_cookie_jar.dart
cookie_jar|lib/src/default_cookie_jar.dart
cookie_jar|lib/src/serializable_cookie.dart
cookie_jar|lib/src/cookie_jar.dart
反应过来我使用到dio的,然后将dio的使用去掉就ok了,去掉dio的使用,代码里去掉dio的import和dio相关使用:
import 'package:flutter_web/material.dart';
// import 'package:dio/dio.dart';
很奇怪的是,之前webdev还是2.0.6-2.0.7都能用的