You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When executing dart pub run build_runner build, the following error occurs:
[SEVERE] Failed to snapshot build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.
[SEVERE] lib/src/example.dart:3:6: Error: Error when reading 'lib/src/example.g.dart': No such file or directorypart 'example.g.dart'; ^lib/src/example.dart:3:6: Error: Can't use 'lib/src/example.g.dart' as a part, because it has no 'part of' declaration.part 'example.g.dart'; ^lib/src/example.dart:11:57: Error: Method not found: '_$PersonFromJson'. factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json); ^^^^^^^^^^^^^^^^lib/src/example.dart:12:36: Error: The method '_$PersonToJson' isn't defined for the class 'Person'. - 'Person' is from 'package:builder_test/src/example.dart' ('lib/src/example.dart').Try correcting the name to the name of an existing method, or defining a method named '_$PersonToJson'. Map<String, dynamic> toJson() => _$PersonToJson(this); ^^^^^^^^^^^^^^
If I comment out the import import 'src/example.dart';, then example.g.dart can be generated successfully.
The text was updated successfully, but these errors were encountered:
There is no supported way of doing this today - you can move the generated files to another package which is the easiest way to deal with it.
Closing as we don't have any actionable plan to deal with this - we do face the same problem in our own repos as well fwiw but there just isn't a good solution we have come up with to manage it.
Dart SDK Version (
dart --version
)Dart SDK version: 2.10.5 (stable) (Tue Jan 19 13:05:37 2021 +0100) on "macos_x64"
What package(s) from this repo you are using, and the version (i.e.
build_runner 0.7.12
)pubspec.lock
file.What builder(s) you are using (or writing yourself). Try to give a short summary of what they do.
Sample repo: https://github.com/lcdsmao/custom-builder-with-build-runner
A builder that import file that needs part generated by json_serializable.
When executing
dart pub run build_runner build
, the following error occurs:If I comment out the import
import 'src/example.dart';
, thenexample.g.dart
can be generated successfully.The text was updated successfully, but these errors were encountered: