Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: I'm having this issue when running: flutter pub run builder_runner watch

Tags:

flutter

dart

This is the error:

Bad state: Unexpected diagnostics:
C:\flutter\bin\cache\dart-sdk\lib\internal\internal.dart:172:16 - This requires the 'non-nullable' 
language feature to be enabled.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:

This just happened after the last flutter upgrade. I've tried many solutions but nothing worked, even i reinstalled the flutter SDK.

This is the pubspec.yaml:

environment:
 sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  json_annotation: ^3.0.1
  cupertino_icons: ^0.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner:
  json_serializable: ^3.3.0

The test code:

import 'package:json_annotation/json_annotation.dart';

part 'test.g.dart';

//@JsonSerializable(nullable: true)
//@JsonSerializable(nullable: false)
@JsonSerializable()
class Test{
  final String test;
  Test(this.test);
}
like image 284
Omar Fayad Avatar asked May 09 '20 00:05

Omar Fayad


People also ask

How do you run flutter pub?

From the terminal: Run flutter pub get . From Android Studio/IntelliJ: Click Packages get in the action ribbon at the top of pubspec. yaml . From VS Code: Click Get Packages located in right side of the action ribbon at the top of pubspec.


1 Answers

simplest way to solve this

  • downgrade environment sdk to 2.1.0

like this

environment:
  sdk: ">=2.1.0 <3.0.0"
like image 143
Mohamed Kamel Avatar answered Sep 20 '22 04:09

Mohamed Kamel