无法在 flutter 中使用构建运行器生成 mobx

rah*_*aha 5 build flutter mobx build-runner

我正在使用mobxflutter 进行状态管理。但在项目中添加后,mobx我无法构建生成的文件。并得到错误

Bad state: Unexpected diagnostics:
C:\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] mobx_codegen:mobx_generator on lib/main.dart:
Run Code Online (Sandbox Code Playgroud)

mobx 文件:-

import 'package:mobx/mobx.dart';

part 'weather_store.g.dart';

class WeatherStore = _WeatherStore with _$WeatherStore;

abstract class _WeatherStore with Store {
  
}
Run Code Online (Sandbox Code Playgroud)

pubspec.yaml:-

  dependencies:
  flutter:
    sdk: flutter
  mobx: ^0.3.10
  flutter_mobx: ^0.3.4+1
  provider: ^3.2.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner:
  mobx_codegen: ^0.3.10+1
Run Code Online (Sandbox Code Playgroud)

如何解决问题?

编辑:- 构建命令flutter packages pub run build_runner watch

Joh*_*Joe 3

对于已经升级到 flutter 版本1.20.1或更高版本的用户,请确保在pubspec.yaml.

dependency_overrides:
  analyzer: '0.39.14'
Run Code Online (Sandbox Code Playgroud)