In my project, I am using the flutter_google_places_sdk but I needed to modify certain things in its interface, so I forked the repository in Github, and I added a dependency override in my pubspec.yaml
to point to my own Github repository for this specific dependency.
The problem is that this package uses freezed a lot to generate some files, and when I run flutter pub run build_runner build
in my project, it doesn't seem to do anything for dependencies.
I even tried to add dependencies to freezed
and freezed_annotation
in my own project, hoping that it would signal build_runner
to look for annotations in dependencies too, but it doesn't work either.
I am guessing that when you publish a package, it publishes generated files as well, but I don't want to publish this plugin, just use it for myself. What is the proper way to integrate this kind of dependency.
NB: After adding freezed-generated files to my fork of flutter_google_places_sdk
as suggested by the chosen solution, I still had the following exception at runtime when calling fetchPlace
, which I did not modify whatsoever, so it seems there might be an issue with the generated files.
flutter: FlutterGooglePlacesSdk::call error: type '_Map<Object?, Object?>' is not a subtype of type 'Map<String, dynamic>' in type cast
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: type '_Map<Object?, Object?>' is not a subtype of type 'Map<String, dynamic>' in type cast
#0 _$$_PlaceFromJson.<anonymous closure> (package:flutter_google_places_sdk_platform_interface/src/types/place.g.dart:12:52)
#1 MappedListIterable.elementAt (dart:_internal/iterable.dart:415:31)
#2 ListIterator.moveNext (dart:_internal/iterable.dart:344:26)
#3 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#4 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#5 new List.of (dart:core-patch/array_patch.dart:52:28)
#6 ListIterable.toList (dart:_internal/iterable.dart:214:7)
#7 _$$_PlaceFromJson (package:flutter_google_places_sdk_platform_interface/src/types/place.g.dart:13:12)
#8 new _$_Place.fromJson (package:flutter_google_places_sdk_platform_interface/src/types/place.freezed.dart:391:7)
#9 _$PlaceFromJson (package:flutter_google_places_sdk_plat<…>
You have to commit auto generated code in you forked repository by avoid in .gitignore
.
I created PR here for your forked repo.
You can generate a code by running command flutter pub run build_runner build
in that flutter_google_places_sdk_platform_interface
folder manually.