Reputation: 181
I have an issue when trying to generate a Json Serializable Generator using Build Runner in Dart. First, I tried to do run flutter packages pub run build_runner build
to generate Json Serializable but it showed that it has a conflicting issue. So I run command --delete-conflicting-outputs
, to solve the conflicting issue.
After that I tried to run flutter packages pub run build_runner build
again to regenerate the Json value. But the result that i got is like this:
So the output was : [INFO] Succeeded after 137ms with 0 outputs (0 actions)
I get so stressed because of it because all of generated-files were deleted. can somebody tell me what was happening and how to solve this issue?
I have been checking everywhere but still haven't found an answer.
Upvotes: 4
Views: 16650
Reputation: 1
With latest flutter version JUST RUN THIS
dart pub run build_runner watch -d
watch
⇾ is for detect the changes automatically and generate.
build
⇾ is for one time generate.
-d is previously refer as "--delete-conflicting-output"
If you are using fvm (Flutter Version Management) then just do this
fvm dart pub run build_runner watch -d
Upvotes: 0
Reputation: 3144
For me, it was ignoring my class because I forgot to include the part declaration, so the class was skipped.
part 'vehicle.g.dart';
Upvotes: 0
Reputation: 47
Try this:
dart run build_runner build --delete-conflicting-output
Upvotes: 0
Reputation: 3386
You should update your pubspec
dependencies:
# Your other regular dependencies here
json_annotation: <latest_version>
dev_dependencies:
# Your other dev_dependencies here
build_runner: <latest_version>
json_serializable: <latest_version>
then run flutter pub run build_runner build
Upvotes: 2
Reputation: 502
flutter pub run build_runner watch --delete-conflicting-outputs
Upvotes: 11
Reputation: 28010
For me it was not having the files underneath the /lib or /bin directories.
Here's a checklist of things to check when Json_serializable generator has succeeded with no outputs, but no files are generated.
Upvotes: 0
Reputation: 73
Make sure the name of the .g.dart is written properly.
I ran into the same issue came here looking for a solution and when did not find one I noticed the name of the file to be generated is case sensitve.
Upvotes: 0