Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR]: Conditionally bundling assets based on flavor #494

Closed
2 tasks done
MerlijnClaeys opened this issue Mar 28, 2024 · 3 comments · Fixed by #530
Closed
2 tasks done

[FR]: Conditionally bundling assets based on flavor #494

MerlijnClaeys opened this issue Mar 28, 2024 · 3 comments · Fixed by #530
Labels
contributions welcome Welcome contribute discussion Want to discuss it enhancement New feature or request
Milestone

Comments

@MerlijnClaeys
Copy link

Is there an existing issue for this?

  • 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

  • I agree to follow this project's Code of Conduct
@MerlijnClaeys MerlijnClaeys added the bug Something isn't working label Mar 28, 2024
@AlexV525
Copy link
Member

Yes it is not supported.

@AlexV525 AlexV525 changed the title [BUG]: Flutter 3.19 feature: Conditionally bundling assets based on flavor not supported [FR]: Conditionally bundling assets based on flavor Mar 28, 2024
@AlexV525 AlexV525 added enhancement New feature or request contributions welcome Welcome contribute discussion Want to discuss it and removed bug Something isn't working labels Mar 28, 2024
@MerlijnClaeys
Copy link
Author

@AlexV525 Are there plans to support this in the future?

@AlexV525
Copy link
Member

@AlexV525 Are there plans to support this in the future?

Not yet. We Will sync in this thread if any idea coming out.

@AlexV525 AlexV525 mentioned this issue Jun 17, 2024
7 tasks
@wasabeef wasabeef added this to the 5.6.0 milestone Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome Welcome contribute discussion Want to discuss it enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants