9

I checked and the file is OK.

Dart 1.23.0 AngularDart 3.1.0

The error I am getting is:

Target of URI hasn't been generated: 'file.g.dart'

enter image description here

Jonathan
  • 4,724
  • 7
  • 45
  • 65
  • What happens if you restart the analysis server? I have seen this often as well. If you have a good reproduction, please create an issue. – Günter Zöchbauer Jun 05 '17 at 15:42
  • I am using webstorm, so I don't know how the analysis server is started. I guess it would reiniciate if I kill all dart processes? I did that and didn't help – Jonathan Jun 05 '17 at 17:34
  • Does the file in your question have a `library ...` and the `timeline.g.dart` file a `part of ...` declaration? – Günter Zöchbauer Jun 05 '17 at 19:52
  • yes and there are more files generated the same way that does not have this error – Jonathan Jun 05 '17 at 20:09

6 Answers6

7

It may help to run "Synchronize" -- bound by default to Ctrl-Q.

You can restart the analyzer on the dart analysis tab, in the top left is a button with arrows running in a circle, if you hover over it it says 'Restart Dart Analysis Server'.

Example picture

David Morgan
  • 466
  • 3
  • 6
4

first check this article : https://flutter.dev/docs/development/data-and-backend/json and make sure of all steps : 1- add dependencies in pubspec.yaml 2- flutter pub get 3- flutter pub upgrade 4- flutter pub run build_runner build

after all, consider that:

part 'timeline.g.dart';

most be your file name which classes are in!

if your file name is difference with your class name, you should use your file name.

Reza Piri
  • 105
  • 1
  • The question was not related to flutter, and has nothing to do with the current build_runner system, he is running on old version of dart and angular. – Hadrien Lejard Nov 18 '20 at 20:34
2

Had the same problem. Fixed it following these steps:

$ flutter pub get 
$ flutter pub upgrade
$ flutter pub run build_runner build --delete-conflicting-outputs
matiszz
  • 556
  • 3
  • 11
0

you want to add this dependency and try it again.

dart pub add freezed
dart pub add freezed_annotation 
dart pub add json_serializable --dev

Your issue will be solved.

-1

Check have you created a constructor for class with no default parameters. Basically automated file is generated but error happens because it can not find a contractor for model

-1

flutter pub run build_runner build

Just run the above command in the console. Everything will be fine

HIMANSHU MISHRA
  • 149
  • 1
  • 18