1

I have been using code generating packages for months, today I ran the command "flutter pub run build_runner build" on one of my projects, everything built, then when I ran it again, I got this error.

/C:/Users/MyPc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.5.0/liib/src/error/best_practices_verifier.dart:1978:14: Error: A non-null value must ber returned since the return type 'String' doesn't allow null.
  String get displayString {

What should I do? It was sudden and unexpected.

This is my pubspec.yaml

name: tutorial
description: A new Flutter project.

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  another_flushbar: ^1.10.23
  auto_route: ^2.2.0
  cupertino_icons: ^1.0.2
  dartz: 0.10.0-nullsafety.2
  firebase_auth: ^1.3.0
  firebase_core: ^1.2.1
  flutter_bloc: ^7.0.1
  freezed_annotation: ^0.14.2
  get_it: ^7.1.3
  google_sign_in: ^5.0.4
  injectable: ^1.4.1
  uuid: ^3.0.4

dev_dependencies:
  flutter_test:
    sdk: flutter
  auto_route_generator: ^2.1.0
  build_runner: null
  flutter_lints: ^1.0.0
  freezed: ^0.14.2
  injectable_generator: ^1.4.1
  lint: ^1.5.3

flutter:
  uses-material-design: true

 
Alexandru Stroescu
  • 1,067
  • 1
  • 9
  • 16

1 Answers1

0

You have to update the packages or you just turn off null safety by changing the pubspec.yaml

environment:
  sdk: ">=2.11.0 <3.0.0"
Hinno Saad
  • 48
  • 3
  • I don't want to turn off null safety and all my packages are up to date, all of them are null safe and worked so far. – Alexandru Stroescu Jul 09 '21 at 19:56
  • freezed_annotation using analyzer 1.5.0 go to the package and change the version of the analyzer to the latest version or go to C:/Users/MyPc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.5.0/liib/src/error/best_practices_verifier.dart line 1978 add a default value to the switch case – Hinno Saad Jul 09 '21 at 22:19
  • Try to add analyzer: ^2.0.0 to your dev_dependencies in pubspec.yaml file. It may work! – Hinno Saad Jul 09 '21 at 22:29