Flutter Web代碼運行問題

一. 打包問題

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章