4

I am using mobx flutter for state management. but after adding the mobx in the project I am unable to build the generated file. and getting the error

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 file :-

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

How to solve the problem?

edit:- command to build flutter packages pub run build_runner watch

rahul Kushwaha
  • 2,395
  • 7
  • 32
  • 64

1 Answers1

3

For those who have upgraded to flutter version 1.20.1 or above, make sure you add this line in pubspec.yaml.

dependency_overrides:
  analyzer: '0.39.14'
John Joe
  • 12,412
  • 16
  • 70
  • 135