无法在Flutter中使用构建运行器生成Mobx

问题描述

我正在使用mobx抖动来进行状态管理。 但是在项目中添加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:

mobx文件:-

import 'package:mobx/mobx.dart';

part 'weather_store.g.dart';

class WeatherStore = _WeatherStore with _$WeatherStore;

abstract class _WeatherStore with Store {
  
}

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

如何解决问题?

编辑:-建立Flutter packages pub run build_runner watch

的命令

解决方法

对于已升级到版本1.20.1或更高版本的用户,请确保在pubspec.yaml中添加此行。

dependency_overrides:
  analyzer: '0.39.14'