flutter_gen
flutter_gen copied to clipboard
[FR]: Conditionally bundling assets based on flavor
Is there an existing issue for this?
- [X] I have searched the existing issues
Version
5.4.0
Command type
build_runner (Default)
What happened?
With the new flutter version 3.19, conditionally bundling assets based on flavor was introduced. As the name suggests, this allows for bundling assets contionally based on flavor of the app. docs
When using flutter_gen to build assets I get the following exception:
FlutterGen v5.4.0 Loading ... my-app/pubspec.yaml Unhandled exception: CheckedFromJsonException Could not createFlutter. There is a problem with "assets". type 'YamlMap' is not a subtype of type 'String' in type cast #0 $checkedConvert (package:json_annotation/src/checked_helpers.dart:91:5) #1 $checkedCreate.checkedConvert (package:json_annotation/src/checked_helpers.dart:28:7) #2 _$FlutterFromJson.<anonymous closure> (package:flutter_gen_core/settings/pubspec.g.dart:38:34) #3 $checkedCreate.<anonymous closure> (package:json_annotation/src/checked_helpers.dart:33:22) #4 $checkedNew (package:json_annotation/src/checked_helpers.dart:51:23) #5 $checkedCreate (package:json_annotation/src/checked_helpers.dart:30:10) #6 _$FlutterFromJson (package:flutter_gen_core/settings/pubspec.g.dart:29:40) #7 new Flutter.fromJson (package:flutter_gen_core/settings/pubspec.dart:40:41) #8 _$PubspecFromJson.<anonymous closure>.<anonymous closure> (package:flutter_gen_core/settings/pubspec.g.dart:22:57) #9 $checkedConvert (package:json_annotation/src/checked_helpers.dart:87:20) #10 $checkedCreate.checkedConvert (package:json_annotation/src/checked_helpers.dart:28:7) #11 _$PubspecFromJson.<anonymous closure> (package:flutter_gen_core/settings/pubspec.g.dart:22:30) #12 $checkedCreate.<anonymous closure> (package:json_annotation/src/checked_helpers.dart:33:22) #13 $checkedNew (package:json_annotation/src/checked_helpers.dart:51:23) #14 $checkedCreate (package:json_annotation/src/checked_helpers.dart:30:10) #15 _$PubspecFromJson (package:flutter_gen_core/settings/pubspec.g.dart:9:40) #16 new Pubspec.fromJson (package:flutter_gen_core/settings/pubspec.dart:15:41) #17 loadPubspecConfig (package:flutter_gen_core/settings/config.dart:28:27) #18 loadPubspecConfigOrNull (package:flutter_gen_core/settings/config.dart:34:12) #19 FlutterGenerator.build (package:flutter_gen_core/flutter_generator.dart:25:16) #20 main (file:///Users/myuser/.pub-cache/hosted/pub.dev/flutter_gen-5.4.0/bin/flutter_gen_command.dart:48:49) #21 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:294:33) #22 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
How my assets are defined in pubspec.yaml
` flutter: uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- path: assets/sandbox/
flavors:
- sandbox
- path: assets/production/
flavors:
- production
`
is this not supported?
Relevant a pubspec.yaml.
flutter_gen:
output: lib/gen/ # Optional (default: lib/gen/)
line_length: 80 # Optional (default: 80)
# Optional
integrations:
flutter_svg: true
flare_flutter: true
rive: true
lottie: true
flutter:
uses-material-design: true
assets:
- path: assets/sandbox/
flavors:
- sandbox
- path: assets/production/
flavors:
- production
Relevant log output
FlutterGen v5.4.0 Loading ... my-app/pubspec.yaml
Unhandled exception:
CheckedFromJsonException
Could not create `Flutter`.
There is a problem with "assets".
type 'YamlMap' is not a subtype of type 'String' in type cast
#0 $checkedConvert (package:json_annotation/src/checked_helpers.dart:91:5)
#1 $checkedCreate.checkedConvert (package:json_annotation/src/checked_helpers.dart:28:7)
#2 _$FlutterFromJson.<anonymous closure> (package:flutter_gen_core/settings/pubspec.g.dart:38:34)
#3 $checkedCreate.<anonymous closure> (package:json_annotation/src/checked_helpers.dart:33:22)
#4 $checkedNew (package:json_annotation/src/checked_helpers.dart:51:23)
#5 $checkedCreate (package:json_annotation/src/checked_helpers.dart:30:10)
#6 _$FlutterFromJson (package:flutter_gen_core/settings/pubspec.g.dart:29:40)
#7 new Flutter.fromJson (package:flutter_gen_core/settings/pubspec.dart:40:41)
#8 _$PubspecFromJson.<anonymous closure>.<anonymous closure> (package:flutter_gen_core/settings/pubspec.g.dart:22:57)
#9 $checkedConvert (package:json_annotation/src/checked_helpers.dart:87:20)
#10 $checkedCreate.checkedConvert (package:json_annotation/src/checked_helpers.dart:28:7)
#11 _$PubspecFromJson.<anonymous closure> (package:flutter_gen_core/settings/pubspec.g.dart:22:30)
#12 $checkedCreate.<anonymous closure> (package:json_annotation/src/checked_helpers.dart:33:22)
#13 $checkedNew (package:json_annotation/src/checked_helpers.dart:51:23)
#14 $checkedCreate (package:json_annotation/src/checked_helpers.dart:30:10)
#15 _$PubspecFromJson (package:flutter_gen_core/settings/pubspec.g.dart:9:40)
#16 new Pubspec.fromJson (package:flutter_gen_core/settings/pubspec.dart:15:41)
#17 loadPubspecConfig (package:flutter_gen_core/settings/config.dart:28:27)
#18 loadPubspecConfigOrNull (package:flutter_gen_core/settings/config.dart:34:12)
#19 FlutterGenerator.build (package:flutter_gen_core/flutter_generator.dart:25:16)
#20 main (file:///Users/myuser/.pub-cache/hosted/pub.dev/flutter_gen-5.4.0/bin/flutter_gen_command.dart:48:49)
#21 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:294:33)
#22 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Yes it is not supported.
@AlexV525 Are there plans to support this in the future?
@AlexV525 Are there plans to support this in the future?
Not yet. We Will sync in this thread if any idea coming out.