From 5fab8caaa3a075f0b9c3deeedc32b372aaac37fa Mon Sep 17 00:00:00 2001 From: Daichi Furiya Date: Tue, 25 Jun 2024 16:09:26 +0900 Subject: [PATCH] release: v5.6.0 (#534) ## 5.6.0 **Bug fix** - [#530](https://github.com/FlutterGen/flutter_gen/pull/530) Fix the Flavored assets. by [@AlexV525](https://github.com/AlexV525) - Please submit issues later if you have any feedback, this is blocking users from generating files if they are using flavors or transformations and there is no workaround for them. - [#532](https://github.com/FlutterGen/flutter_gen/pull/532) Provid the theme to SvgAssetLoader instead of SvgPicture. by [@Kirpal](https://github.com/Kirpal) --- CHANGELOG.md | 7 +++ examples/example/lib/main.dart | 4 ++ examples/example/pubspec.yaml | 2 +- .../example_resources/lib/gen/assets.gen.dart | 58 ++++++++++++++----- examples/example_resources/pubspec.yaml | 2 +- packages/command/pubspec.yaml | 4 +- packages/core/lib/settings/pubspec.g.dart | 2 +- packages/core/lib/version.gen.dart | 2 +- packages/core/pubspec.yaml | 2 +- packages/runner/pubspec.yaml | 4 +- 10 files changed, 64 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44e7646f1..063f63432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 5.6.0 + +**Bug fix** +- [#530](https://github.com/FlutterGen/flutter_gen/pull/530) Fix the Flavored assets. by [@AlexV525](https://github.com/AlexV525) + - Please submit issues later if you have any feedback, this is blocking users from generating files if they are using flavors or transformations and there is no workaround for them. +- [#532](https://github.com/FlutterGen/flutter_gen/pull/532) Provid the theme to SvgAssetLoader instead of SvgPicture. by [@Kirpal](https://github.com/Kirpal) + ## 5.5.0+1 **Feature** diff --git a/examples/example/lib/main.dart b/examples/example/lib/main.dart index 45f5e0952..a19d961d8 100644 --- a/examples/example/lib/main.dart +++ b/examples/example/lib/main.dart @@ -10,6 +10,10 @@ void main() async { // options: DefaultFirebaseOptions.currentPlatform, // ); + // flavors sample + // output: {'extern'} + print(MyAssets.images.chip4.chip4.flavors); + runApp(MaterialApp( title: 'Flutter Demo', theme: ThemeData( diff --git a/examples/example/pubspec.yaml b/examples/example/pubspec.yaml index 4e92cb1d8..1cd4ae7c1 100644 --- a/examples/example/pubspec.yaml +++ b/examples/example/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: dev_dependencies: lints: ^2.0.0 build_runner: ^2.0.0 - flutter_gen_runner: ^5.5.0+1 + flutter_gen_runner: ^5.6.0 flutter_test: sdk: flutter diff --git a/examples/example_resources/lib/gen/assets.gen.dart b/examples/example_resources/lib/gen/assets.gen.dart index 0ce358a51..2dec02207 100644 --- a/examples/example_resources/lib/gen/assets.gen.dart +++ b/examples/example_resources/lib/gen/assets.gen.dart @@ -63,13 +63,18 @@ class ResAssets { } class AssetGenImage { - const AssetGenImage(this._assetName, {this.size = null}); + const AssetGenImage( + this._assetName, { + this.size, + this.flavors = const {}, + }); final String _assetName; static const String package = 'example_resources'; final Size? size; + final Set flavors; Image image({ Key? key, @@ -145,21 +150,23 @@ class AssetGenImage { class SvgGenImage { const SvgGenImage( this._assetName, { - this.size = null, + this.size, + this.flavors = const {}, }) : _isVecFormat = false; const SvgGenImage.vec( this._assetName, { - this.size = null, + this.size, + this.flavors = const {}, }) : _isVecFormat = true; final String _assetName; - - static const String package = 'example_resources'; - final Size? size; + final Set flavors; final bool _isVecFormat; + static const String package = 'example_resources'; + SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -181,12 +188,23 @@ class SvgGenImage { @deprecated BlendMode colorBlendMode = BlendMode.srcIn, @deprecated bool cacheColorFilter = false, }) { + final BytesLoader loader; + if (_isVecFormat) { + loader = AssetBytesLoader( + _assetName, + assetBundle: bundle, + packageName: package, + ); + } else { + loader = SvgAssetLoader( + _assetName, + assetBundle: bundle, + packageName: package, + theme: theme, + ); + } return SvgPicture( - _isVecFormat - ? AssetBytesLoader(_assetName, - assetBundle: bundle, packageName: package) - : SvgAssetLoader(_assetName, - assetBundle: bundle, packageName: package, theme: theme), + loader, key: key, matchTextDirection: matchTextDirection, width: width, @@ -210,9 +228,13 @@ class SvgGenImage { } class FlareGenImage { - const FlareGenImage(this._assetName); + const FlareGenImage( + this._assetName, { + this.flavors = const {}, + }); final String _assetName; + final Set flavors; static const String package = 'example_resources'; @@ -255,9 +277,13 @@ class FlareGenImage { } class RiveGenImage { - const RiveGenImage(this._assetName); + const RiveGenImage( + this._assetName, { + this.flavors = const {}, + }); final String _assetName; + final Set flavors; static const String package = 'example_resources'; @@ -294,9 +320,13 @@ class RiveGenImage { } class LottieGenImage { - const LottieGenImage(this._assetName); + const LottieGenImage( + this._assetName, { + this.flavors = const {}, + }); final String _assetName; + final Set flavors; static const String package = 'example_resources'; diff --git a/examples/example_resources/pubspec.yaml b/examples/example_resources/pubspec.yaml index 35663d4e5..94ead6cc0 100644 --- a/examples/example_resources/pubspec.yaml +++ b/examples/example_resources/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: dev_dependencies: build_runner: ^2.0.0 - flutter_gen_runner: ^5.5.0+1 + flutter_gen_runner: ^5.6.0 flutter_gen: output: lib/gen/ diff --git a/packages/command/pubspec.yaml b/packages/command/pubspec.yaml index bc93dc0c2..2ff39fc2e 100644 --- a/packages/command/pubspec.yaml +++ b/packages/command/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_gen description: The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs. -version: 5.5.0+1 +version: 5.6.0 homepage: https://github.com/FlutterGen/flutter_gen repository: https://github.com/FlutterGen/flutter_gen documentation: https://github.com/FlutterGen/flutter_gen @@ -13,7 +13,7 @@ executables: fluttergen: flutter_gen_command dependencies: - flutter_gen_core: 5.5.0+1 + flutter_gen_core: 5.6.0 args: ^2.0.0 dev_dependencies: diff --git a/packages/core/lib/settings/pubspec.g.dart b/packages/core/lib/settings/pubspec.g.dart index c03f15b07..1c077df8e 100644 --- a/packages/core/lib/settings/pubspec.g.dart +++ b/packages/core/lib/settings/pubspec.g.dart @@ -80,7 +80,7 @@ FlutterGen _$FlutterGenFromJson(Map json) => $checkedCreate( ); final val = FlutterGen( output: $checkedConvert('output', (v) => v as String), - lineLength: $checkedConvert('line_length', (v) => v as int), + lineLength: $checkedConvert('line_length', (v) => (v as num).toInt()), parseMetadata: $checkedConvert('parse_metadata', (v) => v as bool), assets: $checkedConvert( 'assets', (v) => FlutterGenAssets.fromJson(v as Map)), diff --git a/packages/core/lib/version.gen.dart b/packages/core/lib/version.gen.dart index 49fe433dd..f9b6dacc5 100644 --- a/packages/core/lib/version.gen.dart +++ b/packages/core/lib/version.gen.dart @@ -1,2 +1,2 @@ /// DO NOT MODIFY BY HAND, Generated by version_gen -String packageVersion = '5.5.0+1'; +String packageVersion = '5.6.0'; diff --git a/packages/core/pubspec.yaml b/packages/core/pubspec.yaml index a3fb0c2ff..dbf129861 100644 --- a/packages/core/pubspec.yaml +++ b/packages/core/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_gen_core description: The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs. -version: 5.5.0+1 +version: 5.6.0 homepage: https://github.com/FlutterGen/flutter_gen repository: https://github.com/FlutterGen/flutter_gen documentation: https://github.com/FlutterGen/flutter_gen diff --git a/packages/runner/pubspec.yaml b/packages/runner/pubspec.yaml index fa12a4777..30eedc27e 100644 --- a/packages/runner/pubspec.yaml +++ b/packages/runner/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_gen_runner description: The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs. -version: 5.5.0+1 +version: 5.6.0 homepage: https://github.com/FlutterGen/flutter_gen repository: https://github.com/FlutterGen/flutter_gen documentation: https://github.com/FlutterGen/flutter_gen @@ -10,7 +10,7 @@ environment: sdk: '>=2.17.0 <4.0.0' dependencies: - flutter_gen_core: 5.5.0+1 + flutter_gen_core: 5.6.0 build: ^2.0.0 collection: ^1.17.0 crypto: ^3.0.0