2

I am using analyser 1.7.1. The latest build_runner build command generates the following error.

flutter packages pub run build_runner build Failed to precompile build_runner:build_runner: ../../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.7.1/lib/src/error/best_practices_verifier.dart:1998:14: Error: A non-null value must be returned since the return type 'String' doesn't allow null. String get displayString {

The usual flutter clean and pub cache repair commands don't seem to be fixing the problem, and displayString doesn't appear anywhere in my codebase.

Rob Lyndon
  • 12,089
  • 5
  • 49
  • 74

2 Answers2

2

There's an issue open 9 days ago. Here's the key part:

Right now, the current state of affairs is that:

  • package:analyzer 1.7.0 requires package:meta ^1.4.0
  • package:analyzer 1.7.1 has the same contents as 1.7.0, but requires package:meta ^1.3.0
  • Flutter stable pins package:meta to 1.3.0

I'm uncertain how we're running into the exceptions above - the two most recent versions of analyzer are pretty explicit about which version of meta they need.

@edlman do you have any dependency_overrides in your pubspec?

you're right, I'm using 3rd party pkgs which depend on meta 1.4.0 so I put it to dependency_overrides to solve the collision. It didn't come to my mind it cause such a problem. I've changed the override to 1.3.0, it works fine, no problem yet

So I'd suggest checking whether or not there's a dependency_overrides in your pubspec, too.

raina77ow
  • 103,633
  • 15
  • 192
  • 229
2

It's a problem with analyser 1.7.1.

Add

dependency_overrides:
  analyzer: 1.7.0

to pubspec.yaml.

There are more details available in raina77ow's answer.

Rob Lyndon
  • 12,089
  • 5
  • 49
  • 74