From 369489d468feab8b8fbafb3abfd196775106fd41 Mon Sep 17 00:00:00 2001 From: Mairramer Date: Thu, 28 May 2026 10:38:39 -0300 Subject: [PATCH 1/4] refactor: decouple generated asset classes by introducing flutter_gen_interface package --- CHANGELOG.md | 5 + melos.yaml | 3 + .../core/lib/generators/assets_generator.dart | 11 +- .../integrations/image_integration.dart | 110 +---------- .../integrations/svg_integration.dart | 95 +-------- .../test/assets_gen_integrations_test.dart | 15 -- packages/core/test/assets_gen_test.dart | 7 - .../actual_data/assets_assets.gen.dart | 180 +---------------- .../assets_assets_camel_case.gen.dart | 91 +-------- .../assets_assets_change_class_name.gen.dart | 91 +-------- ...assets_assets_deferred_components.gen.dart | 168 +--------------- .../assets_assets_directory_path.gen.dart | 168 +--------------- ...ctory_path_with_package_parameter.gen.dart | 184 +----------------- .../assets_assets_exclude_files.gen.dart | 91 +-------- .../assets_assets_flavored.gen.dart | 168 +--------------- .../assets_assets_no_integrations.gen.dart | 91 +-------- .../assets_assets_package_parameter.gen.dart | 184 +----------------- ...age_parameter_disable_null_safety.gen.dart | 184 +----------------- .../assets_assets_parse_metadata.gen.dart | 168 +--------------- .../assets_assets_snake_case.gen.dart | 91 +-------- .../assets_assets_svg_integrations.gen.dart | 80 +------- .../assets_change_output_path.gen.dart | 91 +-------- .../actual_data/assets_normal.gen.dart | 168 +--------------- .../assets_only_flutter_value.gen.dart | 91 +-------- .../assets_wrong_output_path.gen.dart | 91 +-------- .../build_assets_build_assets.gen.dart | 180 +---------------- .../build_assets_build_empty.gen.dart | 180 +---------------- .../build_assets_build_runner_assets.gen.dart | 179 +---------------- packages/flutter_gen_interface/.gitignore | 31 +++ packages/flutter_gen_interface/.metadata | 10 + packages/flutter_gen_interface/CHANGELOG.md | 1 + packages/flutter_gen_interface/LICENSE | 1 + packages/flutter_gen_interface/README.md | 1 + .../analysis_options.yaml | 1 + .../lib/flutter_gen_interface.dart | 180 +++++++++++++++++ packages/flutter_gen_interface/pubspec.yaml | 22 +++ .../test/flutter_gen_interface_test.dart | 69 +++++++ 37 files changed, 400 insertions(+), 3081 deletions(-) create mode 100644 packages/flutter_gen_interface/.gitignore create mode 100644 packages/flutter_gen_interface/.metadata create mode 120000 packages/flutter_gen_interface/CHANGELOG.md create mode 120000 packages/flutter_gen_interface/LICENSE create mode 120000 packages/flutter_gen_interface/README.md create mode 100644 packages/flutter_gen_interface/analysis_options.yaml create mode 100644 packages/flutter_gen_interface/lib/flutter_gen_interface.dart create mode 100644 packages/flutter_gen_interface/pubspec.yaml create mode 100644 packages/flutter_gen_interface/test/flutter_gen_interface_test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index af39eccea..86d8bba3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## 5.14.1 +**Feature** + +- [#759](https://github.com/FlutterGen/flutter_gen/issues/759) Added `flutter_gen_interface` to allow generated asset classes to implement a shared custom interface for Modular Architectures & Design Systems. + + **Development** - Fix package root resolution after build_runner 2.14.0 AOT changes. by [@Carapacik](https://github.com/Carapacik) diff --git a/melos.yaml b/melos.yaml index 7e262c157..36c25389b 100644 --- a/melos.yaml +++ b/melos.yaml @@ -4,6 +4,7 @@ packages: - packages/command - packages/core - packages/runner + - packages/flutter_gen_interface - examples/example - examples/example_resources - examples/example_workspace @@ -132,6 +133,7 @@ scripts: - flutter_gen - flutter_gen_core - flutter_gen_runner + - flutter_gen_interface publish:dry: run: dart pub publish --dry-run @@ -143,3 +145,4 @@ scripts: - flutter_gen - flutter_gen_core - flutter_gen_runner + - flutter_gen_interface diff --git a/packages/core/lib/generators/assets_generator.dart b/packages/core/lib/generators/assets_generator.dart index f7dfb204a..716602cda 100644 --- a/packages/core/lib/generators/assets_generator.dart +++ b/packages/core/lib/generators/assets_generator.dart @@ -77,7 +77,6 @@ Future generateAssets( 'The value of "flutter/assets:" is incorrect.', ); } - final integrations = [ if (config.flutterGen.integrations.image) ImageIntegration( @@ -165,7 +164,15 @@ Future generateAssets( final importsBuffer = StringBuffer(); for (final e in imports.sorted((a, b) => a.import.compareTo(b.import))) { - importsBuffer.writeln(import(e)); + if (e.import == + 'package:flutter_gen_interface/flutter_gen_interface.dart') { + importsBuffer.writeln( + 'import \'package:flutter_gen_interface/flutter_gen_interface.dart\';'); + importsBuffer.writeln( + 'export \'package:flutter_gen_interface/flutter_gen_interface.dart\';'); + } else { + importsBuffer.writeln(import(e)); + } } final buffer = StringBuffer(); diff --git a/packages/core/lib/generators/integrations/image_integration.dart b/packages/core/lib/generators/integrations/image_integration.dart index ed5a73e91..d24b654dd 100644 --- a/packages/core/lib/generators/integrations/image_integration.dart +++ b/packages/core/lib/generators/integrations/image_integration.dart @@ -25,110 +25,13 @@ class ImageIntegration extends Integration { isPackage ? "'packages/$packageName/\$_assetName'" : '_assetName'; @override - List get requiredImports => const [ - Import('package:flutter/widgets.dart'), + List get requiredImports => [ + const Import( + 'package:flutter_gen_interface/flutter_gen_interface.dart'), ]; @override - String get classOutput => _classDefinition; - - String get _classDefinition => '''class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - -${isPackage ? "\n static const String package = '$packageName';" : ''} - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageParameter, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageParameter, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => $keyName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} -'''; + String get classOutput => ''; @override String get className => 'AssetGenImage'; @@ -157,7 +60,10 @@ class AssetGenImageAnimation { final flavors = asset.flavors.map((e) => '\'$e\'').join(', '); buffer.write(flavors); buffer.write('}'); - buffer.write(','); // Better formatting. + if (!isPackage) buffer.write(','); // Better formatting. + } + if (isPackage) { + buffer.write(', package: \'$packageName\','); } buffer.write(')'); return buffer.toString(); diff --git a/packages/core/lib/generators/integrations/svg_integration.dart b/packages/core/lib/generators/integrations/svg_integration.dart index 86919d88a..3d92d0256 100644 --- a/packages/core/lib/generators/integrations/svg_integration.dart +++ b/packages/core/lib/generators/integrations/svg_integration.dart @@ -13,95 +13,13 @@ class SvgIntegration extends Integration { String get packageExpression => isPackage ? ' = package' : ''; @override - List get requiredImports => const [ - Import('package:flutter/widgets.dart'), - Import('package:flutter/services.dart'), - Import('package:flutter_svg/flutter_svg.dart', alias: '_svg'), - Import('package:vector_graphics/vector_graphics.dart', alias: '_vg'), + List get requiredImports => [ + const Import( + 'package:flutter_gen_interface/flutter_gen_interface.dart'), ]; @override - String get classOutput => _classDefinition; - - String get _classDefinition => '''class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - -${isPackage ? "\n static const String package = '$packageName';" : ''} - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageExpression, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => ${isPackage ? '\'packages/$packageName/\$_assetName\'' : '_assetName'}; -}'''; + String get classOutput => ''; @override String get className => 'SvgGenImage'; @@ -127,7 +45,10 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} final flavors = asset.flavors.map((e) => '\'$e\'').join(', '); buffer.write(flavors); buffer.write('}'); - buffer.write(','); // Better formatting. + if (!isPackage) buffer.write(','); // Better formatting. + } + if (isPackage) { + buffer.write(', package: \'$packageName\','); } buffer.write(')'); return buffer.toString(); diff --git a/packages/core/test/assets_gen_integrations_test.dart b/packages/core/test/assets_gen_integrations_test.dart index e07560f33..bd352eb84 100644 --- a/packages/core/test/assets_gen_integrations_test.dart +++ b/packages/core/test/assets_gen_integrations_test.dart @@ -174,21 +174,6 @@ void main() { isFalse, ); expect(integration.isConstConstructor, isTrue); - expect(integration.classOutput.contains('String? package,'), isTrue); - - final integrationWithPackage = SvgIntegration('package_name'); - expect( - integrationWithPackage.classOutput.contains( - 'String? package = package,', - ), - isTrue, - ); - expect( - integrationWithPackage.classOutput.contains( - "static const String package = 'package_name';", - ), - isTrue, - ); }); test('Assets with Rive integrations on pubspec.yaml', () async { diff --git a/packages/core/test/assets_gen_test.dart b/packages/core/test/assets_gen_test.dart index 38ab09125..9d30c850f 100644 --- a/packages/core/test/assets_gen_test.dart +++ b/packages/core/test/assets_gen_test.dart @@ -59,13 +59,6 @@ void main() { // The generated classes have `package` fields. expect(content, contains("static const String package = 'test';")); - expect( - content, - contains( - "@Deprecated('Do not specify package for a generated library asset')", - ), - ); - expect(content, contains('String? package = package,')); }); test('Assets with directory path enabled', () async { diff --git a/packages/core/test_resources/actual_data/assets_assets.gen.dart b/packages/core/test_resources/actual_data/assets_assets.gen.dart index 8adde2e9e..373067c75 100644 --- a/packages/core/test_resources/actual_data/assets_assets.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -156,177 +154,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart b/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart index 0938c9023..47c2f0695 100644 --- a/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; abstract final class Assets { /// File path: assets/images/chip1.jpg @@ -88,91 +89,3 @@ abstract final class Assets { picturesChip5, ]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart b/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart index dcc0bdc6d..9a84982a0 100644 --- a/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -44,91 +45,3 @@ class $AssetsImagesGen { abstract final class MyAssets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart b/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart index e6b01d080..472f0bdc7 100644 --- a/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -215,165 +213,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart b/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart index 3a7e669c9..e1e2efeb3 100644 --- a/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -76,165 +74,3 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart b/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart index bc03f71dd..42ffff65e 100644 --- a/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -46,7 +44,7 @@ class $AssetsImagesChip3Gen { /// File path: assets/images/chip3/chip3.jpg AssetGenImage get chip3 => - const AssetGenImage('assets/images/chip3/chip3.jpg'); + const AssetGenImage('assets/images/chip3/chip3.jpg', package: 'test'); /// Directory path: packages/test/assets/images/chip3 String get path => 'packages/test/assets/images/chip3'; @@ -60,11 +58,11 @@ class $AssetsImagesIconsGen { /// File path: assets/images/icons/dart@test.svg SvgGenImage get dartTest => - const SvgGenImage('assets/images/icons/dart@test.svg'); + const SvgGenImage('assets/images/icons/dart@test.svg', package: 'test'); /// File path: assets/images/icons/fuchsia.svg SvgGenImage get fuchsia => - const SvgGenImage('assets/images/icons/fuchsia.svg'); + const SvgGenImage('assets/images/icons/fuchsia.svg', package: 'test'); /// Directory path: packages/test/assets/images/icons String get path => 'packages/test/assets/images/icons'; @@ -79,175 +77,3 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - static const String package = 'test'; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - }) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - static const String package = 'test'; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_exclude_files.gen.dart b/packages/core/test_resources/actual_data/assets_assets_exclude_files.gen.dart index 10386b381..176bacaf3 100644 --- a/packages/core/test_resources/actual_data/assets_assets_exclude_files.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_exclude_files.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -69,91 +70,3 @@ abstract final class Assets { static const $AssetsJsonGen json = $AssetsJsonGen(); static const $PicturesGen pictures = $PicturesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart b/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart index 73fc62631..0d6bdf2df 100644 --- a/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -161,165 +159,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart index 751ba7516..34f634e51 100644 --- a/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -119,91 +120,3 @@ abstract final class Assets { static const $AssetsJsonGen json = $AssetsJsonGen(); static const $PicturesGen pictures = $PicturesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart b/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart index 256184310..996a8ce47 100644 --- a/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -40,7 +38,7 @@ class $AssetsImagesChip3Gen { /// File path: assets/images/chip3/chip3.jpg AssetGenImage get chip3 => - const AssetGenImage('assets/images/chip3/chip3.jpg'); + const AssetGenImage('assets/images/chip3/chip3.jpg', package: 'test'); /// List of all assets List get values => [chip3]; @@ -51,11 +49,11 @@ class $AssetsImagesIconsGen { /// File path: assets/images/icons/dart@test.svg SvgGenImage get dartTest => - const SvgGenImage('assets/images/icons/dart@test.svg'); + const SvgGenImage('assets/images/icons/dart@test.svg', package: 'test'); /// File path: assets/images/icons/fuchsia.svg SvgGenImage get fuchsia => - const SvgGenImage('assets/images/icons/fuchsia.svg'); + const SvgGenImage('assets/images/icons/fuchsia.svg', package: 'test'); /// List of all assets List get values => [dartTest, fuchsia]; @@ -67,175 +65,3 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - static const String package = 'test'; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - }) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - static const String package = 'test'; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart b/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart index 582ea7491..0d06b1969 100644 --- a/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -29,7 +27,7 @@ class $AssetsImagesChip3Gen { /// File path: assets/images/chip3/chip3.jpg AssetGenImage get chip3 => - const AssetGenImage('assets/images/chip3/chip3.jpg'); + const AssetGenImage('assets/images/chip3/chip3.jpg', package: 'test'); /// List of all assets List get values => [chip3]; @@ -40,11 +38,11 @@ class $AssetsImagesIconsGen { /// File path: assets/images/icons/dart@test.svg SvgGenImage get dartTest => - const SvgGenImage('assets/images/icons/dart@test.svg'); + const SvgGenImage('assets/images/icons/dart@test.svg', package: 'test'); /// File path: assets/images/icons/fuchsia.svg SvgGenImage get fuchsia => - const SvgGenImage('assets/images/icons/fuchsia.svg'); + const SvgGenImage('assets/images/icons/fuchsia.svg', package: 'test'); /// List of all assets List get values => [dartTest, fuchsia]; @@ -55,175 +53,3 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - static const String package = 'test'; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - }) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - static const String package = 'test'; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart b/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart index 451729d22..8235ad224 100644 --- a/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -203,165 +201,3 @@ abstract final class Assets { static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); static const $PicturesGen pictures = $PicturesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart b/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart index e985f6163..26cbfca9d 100644 --- a/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; abstract final class Assets { /// File path: assets/images/chip1.jpg @@ -89,91 +90,3 @@ abstract final class Assets { pictures_chip5, ]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart index 351ef6d8f..5c5d281f4 100644 --- a/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -42,77 +40,3 @@ class $AssetsImagesIconsGen { abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart b/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart index c37ee5819..7aa194151 100644 --- a/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -44,91 +45,3 @@ class $AssetsImagesGen { abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_normal.gen.dart b/packages/core/test_resources/actual_data/assets_normal.gen.dart index 415b35446..6eeb0c571 100644 --- a/packages/core/test_resources/actual_data/assets_normal.gen.dart +++ b/packages/core/test_resources/actual_data/assets_normal.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -124,165 +122,3 @@ abstract final class Assets { static const $AssetsJsonGen json = $AssetsJsonGen(); static const $PicturesGen pictures = $PicturesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart b/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart index c37ee5819..7aa194151 100644 --- a/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart +++ b/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -44,91 +45,3 @@ class $AssetsImagesGen { abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart b/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart index c37ee5819..7aa194151 100644 --- a/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -44,91 +45,3 @@ class $AssetsImagesGen { abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart b/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart index 8adde2e9e..373067c75 100644 --- a/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -156,177 +154,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart b/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart index 8adde2e9e..373067c75 100644 --- a/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -156,177 +154,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart b/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart index 1e6da27b6..97d196c97 100644 --- a/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -149,176 +147,3 @@ abstract final class BuildAssets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/flutter_gen_interface/.gitignore b/packages/flutter_gen_interface/.gitignore new file mode 100644 index 000000000..dd5eb9895 --- /dev/null +++ b/packages/flutter_gen_interface/.gitignore @@ -0,0 +1,31 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.flutter-plugins-dependencies +/build/ +/coverage/ diff --git a/packages/flutter_gen_interface/.metadata b/packages/flutter_gen_interface/.metadata new file mode 100644 index 000000000..28c719b7c --- /dev/null +++ b/packages/flutter_gen_interface/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "78d2ce61029f9cd4271f0bcca8a6a178c59455d3" + channel: "[user-branch]" + +project_type: package diff --git a/packages/flutter_gen_interface/CHANGELOG.md b/packages/flutter_gen_interface/CHANGELOG.md new file mode 120000 index 000000000..699cc9e7b --- /dev/null +++ b/packages/flutter_gen_interface/CHANGELOG.md @@ -0,0 +1 @@ +../../CHANGELOG.md \ No newline at end of file diff --git a/packages/flutter_gen_interface/LICENSE b/packages/flutter_gen_interface/LICENSE new file mode 120000 index 000000000..30cff7403 --- /dev/null +++ b/packages/flutter_gen_interface/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/packages/flutter_gen_interface/README.md b/packages/flutter_gen_interface/README.md new file mode 120000 index 000000000..fe8400541 --- /dev/null +++ b/packages/flutter_gen_interface/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/packages/flutter_gen_interface/analysis_options.yaml b/packages/flutter_gen_interface/analysis_options.yaml new file mode 100644 index 000000000..fac60e247 --- /dev/null +++ b/packages/flutter_gen_interface/analysis_options.yaml @@ -0,0 +1 @@ +include: ../../analysis_options.yaml \ No newline at end of file diff --git a/packages/flutter_gen_interface/lib/flutter_gen_interface.dart b/packages/flutter_gen_interface/lib/flutter_gen_interface.dart new file mode 100644 index 000000000..19f3aa2d0 --- /dev/null +++ b/packages/flutter_gen_interface/lib/flutter_gen_interface.dart @@ -0,0 +1,180 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:vector_graphics/vector_graphics.dart'; + +class AssetGenImage { + const AssetGenImage( + this._assetName, { + this.size, + this.flavors = const {}, + this.package, + this.animation, + }); + + final String _assetName; + final String? package; + final Size? size; + final Set flavors; + final AssetGenImageAnimation? animation; + + Image image({ + Key? key, + AssetBundle? bundle, + ImageFrameBuilder? frameBuilder, + ImageErrorWidgetBuilder? errorBuilder, + String? semanticLabel, + bool excludeFromSemantics = false, + double? scale, + double? width, + double? height, + Color? color, + Animation? opacity, + BlendMode? colorBlendMode, + BoxFit? fit, + AlignmentGeometry alignment = Alignment.center, + ImageRepeat repeat = ImageRepeat.noRepeat, + Rect? centerSlice, + bool matchTextDirection = false, + bool gaplessPlayback = true, + bool isAntiAlias = false, + String? package, + FilterQuality filterQuality = FilterQuality.medium, + int? cacheWidth, + int? cacheHeight, + }) { + return Image.asset( + _assetName, + key: key, + bundle: bundle, + frameBuilder: frameBuilder, + errorBuilder: errorBuilder, + semanticLabel: semanticLabel, + excludeFromSemantics: excludeFromSemantics, + scale: scale, + width: width, + height: height, + color: color, + opacity: opacity, + colorBlendMode: colorBlendMode, + fit: fit, + alignment: alignment, + repeat: repeat, + centerSlice: centerSlice, + matchTextDirection: matchTextDirection, + gaplessPlayback: gaplessPlayback, + isAntiAlias: isAntiAlias, + package: package ?? this.package, + filterQuality: filterQuality, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + ); + } + + ImageProvider provider({ + AssetBundle? bundle, + String? package, + }) { + return AssetImage( + _assetName, + bundle: bundle, + package: package ?? this.package, + ); + } + + String get path => _assetName; + + String get keyName => + package == null ? _assetName : 'packages/$package/$_assetName'; +} + +class AssetGenImageAnimation { + const AssetGenImageAnimation({ + required this.isAnimation, + required this.duration, + required this.frames, + }); + + final bool isAnimation; + final Duration duration; + final int frames; +} + +class SvgGenImage { + const SvgGenImage( + this._assetName, { + this.size, + this.flavors = const {}, + this.package, + }) : _isVecFormat = false; + + const SvgGenImage.vec( + this._assetName, { + this.size, + this.flavors = const {}, + this.package, + }) : _isVecFormat = true; + + final String _assetName; + final Size? size; + final Set flavors; + final bool _isVecFormat; + final String? package; + + SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + SvgTheme? theme, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @Deprecated('Use colorFilter instead') Color? color, + @Deprecated('Use colorFilter instead') + BlendMode colorBlendMode = BlendMode.srcIn, + @Deprecated('This no longer does anything') bool cacheColorFilter = false, + }) { + final bytesLoader = _isVecFormat + ? AssetBytesLoader( + _assetName, + assetBundle: bundle, + packageName: package ?? this.package, + ) + : SvgAssetLoader( + _assetName, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + ); + return SvgPicture( + bytesLoader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + // ignore: deprecated_member_use + cacheColorFilter: cacheColorFilter, + ); + } + + String get path => _assetName; + + String get keyName => + package == null ? _assetName : 'packages/$package/$_assetName'; +} diff --git a/packages/flutter_gen_interface/pubspec.yaml b/packages/flutter_gen_interface/pubspec.yaml new file mode 100644 index 000000000..05d2ed040 --- /dev/null +++ b/packages/flutter_gen_interface/pubspec.yaml @@ -0,0 +1,22 @@ +name: flutter_gen_interface +description: "A package exposing the XXXGenImage classes used by flutter_gen so modular packages can share the same inheritance tree." +version: 1.0.0 +homepage: https://github.com/FlutterGen/flutter_gen +repository: https://github.com/FlutterGen/flutter_gen/tree/main/packages/flutter_gen_interface +documentation: https://github.com/FlutterGen/flutter_gen +issue_tracker: https://github.com/FlutterGen/flutter_gen/issues + +environment: + sdk: '>=3.0.0 <4.0.0' + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + flutter_svg: '>=2.0.0 <3.0.0' + vector_graphics: '>=1.1.9 <2.0.0' + +dev_dependencies: + flutter_test: + sdk: flutter + lints: any # Ignoring the version to allow editing across SDK versions. diff --git a/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart b/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart new file mode 100644 index 000000000..6ddda1eaa --- /dev/null +++ b/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart @@ -0,0 +1,69 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:vector_graphics/vector_graphics.dart'; + +void main() { + group('AssetGenImage', () { + test('properties and keyName', () { + const image = AssetGenImage('assets/image.png'); + expect(image.path, 'assets/image.png'); + expect(image.keyName, 'assets/image.png'); + + const packageImage = AssetGenImage('assets/image.png', package: 'pkg'); + expect(packageImage.path, 'assets/image.png'); + expect(packageImage.keyName, r'packages/pkg/assets/image.png'); + }); + + testWidgets('provider returns AssetImage', (tester) async { + const image = AssetGenImage('assets/image.png'); + final provider = image.provider() as AssetImage; + expect(provider.assetName, 'assets/image.png'); + expect(provider.package, isNull); + + const packageImage = AssetGenImage('assets/image.png', package: 'pkg'); + final packageProvider = packageImage.provider() as AssetImage; + expect(packageProvider.assetName, 'assets/image.png'); + expect(packageProvider.package, 'pkg'); + }); + + testWidgets('image returns Image widget', (tester) async { + const image = AssetGenImage('assets/image.png'); + final widget = image.image(); + expect(widget.image, isA()); + final assetImage = widget.image as AssetImage; + expect(assetImage.assetName, 'assets/image.png'); + }); + }); + + group('SvgGenImage', () { + test('properties and keyName', () { + const svg = SvgGenImage('assets/icon.svg'); + expect(svg.path, 'assets/icon.svg'); + expect(svg.keyName, 'assets/icon.svg'); + + const packageSvg = SvgGenImage('assets/icon.svg', package: 'pkg'); + expect(packageSvg.path, 'assets/icon.svg'); + expect(packageSvg.keyName, r'packages/pkg/assets/icon.svg'); + }); + + testWidgets('svg returns SvgPicture widget', (tester) async { + const svg = SvgGenImage('assets/icon.svg'); + final widget = svg.svg(); + expect(widget.bytesLoader, isA()); + final loader = widget.bytesLoader as SvgAssetLoader; + expect(loader.assetName, 'assets/icon.svg'); + expect(loader.packageName, isNull); + }); + + testWidgets('vec returns SvgPicture widget with AssetBytesLoader', (tester) async { + const vec = SvgGenImage.vec('assets/icon.vec'); + final widget = vec.svg(); + expect(widget.bytesLoader, isA()); + final loader = widget.bytesLoader as AssetBytesLoader; + expect(loader.assetName, 'assets/icon.vec'); + expect(loader.packageName, isNull); + }); + }); +} From 75eda5c4c33520684dd4492a1a2b3f37275755c0 Mon Sep 17 00:00:00 2001 From: Mairramer Date: Thu, 28 May 2026 10:45:54 -0300 Subject: [PATCH 2/4] feat: bump version to 5.15.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86d8bba3b..c8687cb54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 5.14.1 +## 5.15.0 **Feature** From eb74ed87c0d079c3d66597b5a95dbf9da997119a Mon Sep 17 00:00:00 2001 From: Mairramer Date: Thu, 28 May 2026 10:47:55 -0300 Subject: [PATCH 3/4] fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8687cb54..5e500ecb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#759](https://github.com/FlutterGen/flutter_gen/issues/759) Added `flutter_gen_interface` to allow generated asset classes to implement a shared custom interface for Modular Architectures & Design Systems. +## 5.14.1 **Development** From ece0fae879bfc5b5544bf2b5120a1cf503935529 Mon Sep 17 00:00:00 2001 From: Mairramer Date: Fri, 28 Aug 2026 15:43:23 -0300 Subject: [PATCH 4/4] refactor: implement SvgGenImageExtension for optimized vector graphics and update generated asset classes --- examples/example/lib/gen/assets.gen.dart | 4 +- examples/example/lib/gen/colors.gen.dart | 4 +- examples/example/lib/gen/fonts.gen.dart | 4 +- .../example_resources/lib/gen/assets.gen.dart | 4 +- .../example_resources/lib/gen/colors.gen.dart | 4 +- .../gallery_one/lib/gen/assets.gen.dart | 4 +- .../gallery_two/lib/gen/assets.gen.dart | 4 +- .../core/lib/generators/assets_generator.dart | 6 +- .../integrations/image_integration.dart | 7 +- .../integrations/svg_integration.dart | 71 ++++++++- .../test/assets_gen_integrations_test.dart | 26 ++++ .../actual_data/assets_assets.gen.dart | 62 ++++++++ .../assets_assets_camel_case.gen.dart | 30 ++-- .../assets_assets_change_class_name.gen.dart | 12 +- ...assets_assets_deferred_components.gen.dart | 78 +++++++++- .../assets_assets_directory_path.gen.dart | 62 ++++++++ ...ctory_path_with_package_parameter.gen.dart | 63 ++++++++ .../assets_assets_flavored.gen.dart | 74 +++++++++- ...assets_assets_lottie_integrations.gen.dart | 12 +- .../assets_assets_no_integrations.gen.dart | 12 +- .../assets_assets_package_parameter.gen.dart | 63 ++++++++ ...age_parameter_disable_null_safety.gen.dart | 63 ++++++++ .../assets_assets_parse_metadata.gen.dart | 138 +++++++++++++----- .../assets_assets_snake_case.gen.dart | 30 ++-- .../assets_assets_svg_integrations.gen.dart | 62 ++++++++ .../assets_change_output_path.gen.dart | 12 +- .../actual_data/assets_normal.gen.dart | 74 +++++++++- .../assets_only_flutter_value.gen.dart | 12 +- .../assets_wrong_output_path.gen.dart | 12 +- .../build_assets_build_assets.gen.dart | 62 ++++++++ .../build_assets_build_empty.gen.dart | 62 ++++++++ .../build_assets_build_runner_assets.gen.dart | 83 ++++++++++- .../colors_change_output_path.gen.dart | 54 +++---- .../colors_colors_change_class_name.gen.dart | 54 +++---- .../actual_data/colors_normal.gen.dart | 54 +++---- .../colors_only_flutter_gen_value.gen.dart | 54 +++---- .../colors_wrong_output_path.gen.dart | 54 +++---- .../lib/flutter_gen_interface.dart | 57 +------- packages/flutter_gen_interface/pubspec.yaml | 3 +- .../test/flutter_gen_interface_test.dart | 44 +++--- 40 files changed, 1229 insertions(+), 361 deletions(-) diff --git a/examples/example/lib/gen/assets.gen.dart b/examples/example/lib/gen/assets.gen.dart index 62a550943..a355bebe5 100644 --- a/examples/example/lib/gen/assets.gen.dart +++ b/examples/example/lib/gen/assets.gen.dart @@ -220,7 +220,9 @@ class $AssetsLottieWrongGen { List get values => [dummy, rocketLottieV439]; } -abstract final class MyAssets { +class MyAssets { + const MyAssets._(); + static const String readme = 'README.md'; static const $AssetsFlareGen flare = $AssetsFlareGen(); static const $AssetsImagesGen images = $AssetsImagesGen(); diff --git a/examples/example/lib/gen/colors.gen.dart b/examples/example/lib/gen/colors.gen.dart index df45e8c44..59d20c8c1 100644 --- a/examples/example/lib/gen/colors.gen.dart +++ b/examples/example/lib/gen/colors.gen.dart @@ -11,7 +11,9 @@ import 'package:flutter/painting.dart'; import 'package:flutter/material.dart'; -abstract final class MyColorName { +class MyColorName { + MyColorName._(); + /// Color: #000000 static const Color black = Color(0xFF000000); diff --git a/examples/example/lib/gen/fonts.gen.dart b/examples/example/lib/gen/fonts.gen.dart index f0692db44..82d6f8681 100644 --- a/examples/example/lib/gen/fonts.gen.dart +++ b/examples/example/lib/gen/fonts.gen.dart @@ -8,7 +8,9 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -abstract final class MyFontFamily { +class MyFontFamily { + MyFontFamily._(); + /// Font family: Raleway static const String raleway = 'Raleway'; diff --git a/examples/example_resources/lib/gen/assets.gen.dart b/examples/example_resources/lib/gen/assets.gen.dart index 64f3098e1..11033d91d 100644 --- a/examples/example_resources/lib/gen/assets.gen.dart +++ b/examples/example_resources/lib/gen/assets.gen.dart @@ -56,7 +56,9 @@ class $AssetsUnknownGen { List get values => [unknownMimeType]; } -abstract final class ResAssets { +class ResAssets { + const ResAssets._(); + static const String package = 'example_resources'; static const $AssetsImagesGen images = $AssetsImagesGen(); diff --git a/examples/example_resources/lib/gen/colors.gen.dart b/examples/example_resources/lib/gen/colors.gen.dart index e0427b249..f10d13680 100644 --- a/examples/example_resources/lib/gen/colors.gen.dart +++ b/examples/example_resources/lib/gen/colors.gen.dart @@ -11,7 +11,9 @@ import 'package:flutter/painting.dart'; import 'package:flutter/material.dart'; -abstract final class ColorName { +class ColorName { + ColorName._(); + /// Color: #000000 static const Color black = Color(0xFF000000); diff --git a/examples/example_workspace/packages/gallery_one/lib/gen/assets.gen.dart b/examples/example_workspace/packages/gallery_one/lib/gen/assets.gen.dart index d52839e6e..980d210c7 100644 --- a/examples/example_workspace/packages/gallery_one/lib/gen/assets.gen.dart +++ b/examples/example_workspace/packages/gallery_one/lib/gen/assets.gen.dart @@ -22,7 +22,9 @@ class $AssetsImagesGen { List get values => [flutter3]; } -abstract final class GalleryOneAssets { +class GalleryOneAssets { + const GalleryOneAssets._(); + static const $AssetsImagesGen images = $AssetsImagesGen(); } diff --git a/examples/example_workspace/packages/gallery_two/lib/gen/assets.gen.dart b/examples/example_workspace/packages/gallery_two/lib/gen/assets.gen.dart index 9164790f5..006c08334 100644 --- a/examples/example_workspace/packages/gallery_two/lib/gen/assets.gen.dart +++ b/examples/example_workspace/packages/gallery_two/lib/gen/assets.gen.dart @@ -19,6 +19,8 @@ class $AssetsImagesGen { List get values => [dart]; } -abstract final class GalleryTwoAssets { +class GalleryTwoAssets { + const GalleryTwoAssets._(); + static const $AssetsImagesGen images = $AssetsImagesGen(); } diff --git a/packages/core/lib/generators/assets_generator.dart b/packages/core/lib/generators/assets_generator.dart index 716602cda..dd4ad5128 100644 --- a/packages/core/lib/generators/assets_generator.dart +++ b/packages/core/lib/generators/assets_generator.dart @@ -167,9 +167,11 @@ Future generateAssets( if (e.import == 'package:flutter_gen_interface/flutter_gen_interface.dart') { importsBuffer.writeln( - 'import \'package:flutter_gen_interface/flutter_gen_interface.dart\';'); + 'import \'package:flutter_gen_interface/flutter_gen_interface.dart\';', + ); importsBuffer.writeln( - 'export \'package:flutter_gen_interface/flutter_gen_interface.dart\';'); + 'export \'package:flutter_gen_interface/flutter_gen_interface.dart\';', + ); } else { importsBuffer.writeln(import(e)); } diff --git a/packages/core/lib/generators/integrations/image_integration.dart b/packages/core/lib/generators/integrations/image_integration.dart index d24b654dd..ba1cea69d 100644 --- a/packages/core/lib/generators/integrations/image_integration.dart +++ b/packages/core/lib/generators/integrations/image_integration.dart @@ -25,9 +25,10 @@ class ImageIntegration extends Integration { isPackage ? "'packages/$packageName/\$_assetName'" : '_assetName'; @override - List get requiredImports => [ - const Import( - 'package:flutter_gen_interface/flutter_gen_interface.dart'), + List get requiredImports => const [ + Import( + 'package:flutter_gen_interface/flutter_gen_interface.dart', + ), ]; @override diff --git a/packages/core/lib/generators/integrations/svg_integration.dart b/packages/core/lib/generators/integrations/svg_integration.dart index 3d92d0256..dbdba0d0e 100644 --- a/packages/core/lib/generators/integrations/svg_integration.dart +++ b/packages/core/lib/generators/integrations/svg_integration.dart @@ -10,16 +10,75 @@ class SvgIntegration extends Integration { super.parseMetadata, }) : super(packageName); - String get packageExpression => isPackage ? ' = package' : ''; - @override - List get requiredImports => [ - const Import( - 'package:flutter_gen_interface/flutter_gen_interface.dart'), + List get requiredImports => const [ + Import('package:flutter_gen_interface/flutter_gen_interface.dart'), + Import('package:flutter/widgets.dart'), + Import('package:flutter/services.dart'), + Import('package:flutter_svg/flutter_svg.dart', alias: '_svg'), + Import('package:vector_graphics/vector_graphics.dart', alias: '_vg'), ]; @override - String get classOutput => ''; + String get classOutput => _classDefinition; + + String get _classDefinition => + '''extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +}'''; @override String get className => 'SvgGenImage'; diff --git a/packages/core/test/assets_gen_integrations_test.dart b/packages/core/test/assets_gen_integrations_test.dart index bd352eb84..1f3fc65f3 100644 --- a/packages/core/test/assets_gen_integrations_test.dart +++ b/packages/core/test/assets_gen_integrations_test.dart @@ -174,6 +174,32 @@ void main() { isFalse, ); expect(integration.isConstConstructor, isTrue); + expect( + integration.classOutput.contains( + 'extension SvgGenImageExtension on SvgGenImage', + ), + isTrue, + ); + expect(integration.classOutput.contains('String? package,'), isTrue); + + final integrationWithPackage = SvgIntegration('package_name'); + expect( + integrationWithPackage.classOutput.contains( + "@Deprecated('Do not specify package for a generated library asset')", + ), + isTrue, + ); + expect( + integrationWithPackage.classInstantiate( + AssetType( + rootPath: resPath, + path: 'assets/path/dog.svg', + flavors: {}, + transformers: {}, + ), + ), + "SvgGenImage('assets/path/dog.svg', package: 'package_name',)", + ); }); test('Assets with Rive integrations on pubspec.yaml', () async { diff --git a/packages/core/test_resources/actual_data/assets_assets.gen.dart b/packages/core/test_resources/actual_data/assets_assets.gen.dart index 373067c75..c1d722171 100644 --- a/packages/core/test_resources/actual_data/assets_assets.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $PicturesGen { const $PicturesGen(); @@ -154,3 +158,61 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart b/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart index 47c2f0695..2eb6e519a 100644 --- a/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart @@ -73,19 +73,19 @@ abstract final class Assets { /// List of all assets static List get values => [ - imagesChip1, - imagesChip2, - imagesChip3Chip3, - imagesChip4Chip4, - imagesIconsDartTest, - imagesIconsFuchsia, - imagesIconsKmm, - imagesIconsPaint, - imagesLogo, - imagesProfileJpg, - imagesProfilePng, - jsonList, - jsonMap, - picturesChip5, - ]; + imagesChip1, + imagesChip2, + imagesChip3Chip3, + imagesChip4Chip4, + imagesIconsDartTest, + imagesIconsFuchsia, + imagesIconsKmm, + imagesIconsPaint, + imagesLogo, + imagesProfileJpg, + imagesProfilePng, + jsonList, + jsonMap, + picturesChip5, + ]; } diff --git a/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart b/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart index 9a84982a0..613b95222 100644 --- a/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart @@ -34,12 +34,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } abstract final class MyAssets { diff --git a/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart b/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart index 472f0bdc7..ef2b4c52e 100644 --- a/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $PicturesGen { const $PicturesGen(); @@ -77,12 +81,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -127,8 +131,8 @@ class $AssetsDeferredComponentImagesGen { /// File path: assets/deferred_component/images/component_logo.png AssetGenImage get componentLogo => const AssetGenImage( - 'assets/deferred_component/images/component_logo.png', - ); + 'assets/deferred_component/images/component_logo.png', + ); /// List of all assets List get values => [chip1, componentLogo]; @@ -213,3 +217,61 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart b/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart index e1e2efeb3..ced177e04 100644 --- a/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -74,3 +78,61 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart b/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart index 42ffff65e..d2fbecafa 100644 --- a/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -77,3 +81,62 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + @Deprecated('Do not specify package for a generated library asset') + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart b/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart index 0d6bdf2df..596880d7f 100644 --- a/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $PicturesGen { const $PicturesGen(); @@ -63,12 +67,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -159,3 +163,61 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_assets_lottie_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_assets_lottie_integrations.gen.dart index 6bdba907c..e5bd63f55 100644 --- a/packages/core/test_resources/actual_data/assets_assets_lottie_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_lottie_integrations.gen.dart @@ -33,11 +33,11 @@ class $AssetsLottieGen { /// List of all assets List get values => [ - xuiIZ9X1Rf, - catCat, - hamburgerArrow, - spinningCarrousel, - ]; + xuiIZ9X1Rf, + catCat, + hamburgerArrow, + spinningCarrousel, + ]; } abstract final class Assets { @@ -63,7 +63,7 @@ class LottieGenImage { Key? key, AssetBundle? bundle, Widget Function(BuildContext, Widget, _lottie.LottieComposition?)? - frameBuilder, + frameBuilder, ImageErrorWidgetBuilder? errorBuilder, double? width, double? height, diff --git a/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart index 34f634e51..5182ff83a 100644 --- a/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart @@ -53,12 +53,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { diff --git a/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart b/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart index 996a8ce47..9fcbd54ef 100644 --- a/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -65,3 +69,62 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + @Deprecated('Do not specify package for a generated library asset') + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart b/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart index 0d06b1969..815e68e5d 100644 --- a/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -53,3 +57,62 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + @Deprecated('Do not specify package for a generated library asset') + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart b/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart index 8235ad224..c2a0adb92 100644 --- a/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $PicturesGen { const $PicturesGen(); @@ -41,9 +45,9 @@ class $AssetsImagesGen { /// File path: assets/images/chip1.jpg AssetGenImage get chip1 => const AssetGenImage( - 'assets/images/chip1.jpg', - size: const Size(600.0, 403.0), - ); + 'assets/images/chip1.jpg', + size: const Size(600.0, 403.0), + ); /// File path: assets/images/chip2.jpg AssetGenImage get chip2 => const AssetGenImage('assets/images/chip2.jpg'); @@ -59,9 +63,9 @@ class $AssetsImagesGen { /// File path: assets/images/logo.png AssetGenImage get logo => const AssetGenImage( - 'assets/images/logo.png', - size: const Size(209.0, 49.0), - ); + 'assets/images/logo.png', + size: const Size(209.0, 49.0), + ); /// File path: assets/images/profile.jpg AssetGenImage get profileJpg => @@ -73,12 +77,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -119,14 +123,14 @@ class $AssetsImagesAnimatedGen { /// File path: assets/images/animated/emoji_hugging_face.webp AssetGenImage get emojiHuggingFace => const AssetGenImage( - 'assets/images/animated/emoji_hugging_face.webp', - size: const Size(512.0, 512.0), - animation: const AssetGenImageAnimation( - isAnimation: true, - duration: Duration(milliseconds: 2970), - frames: 45, - ), - ); + 'assets/images/animated/emoji_hugging_face.webp', + size: const Size(512.0, 512.0), + animation: const AssetGenImageAnimation( + isAnimation: true, + duration: Duration(milliseconds: 2970), + frames: 45, + ), + ); /// List of all assets List get values => [emojiHuggingFace]; @@ -137,9 +141,9 @@ class $AssetsImagesChip3Gen { /// File path: assets/images/chip3/chip3.jpg AssetGenImage get chip3 => const AssetGenImage( - 'assets/images/chip3/chip3.jpg', - size: const Size(600.0, 403.0), - ); + 'assets/images/chip3/chip3.jpg', + size: const Size(600.0, 403.0), + ); /// List of all assets List get values => [chip3]; @@ -150,9 +154,9 @@ class $AssetsImagesChip4Gen { /// File path: assets/images/chip4/chip4.jpg AssetGenImage get chip4 => const AssetGenImage( - 'assets/images/chip4/chip4.jpg', - size: const Size(600.0, 403.0), - ); + 'assets/images/chip4/chip4.jpg', + size: const Size(600.0, 403.0), + ); /// List of all assets List get values => [chip4]; @@ -163,15 +167,15 @@ class $AssetsImagesIconsGen { /// File path: assets/images/icons/dart@test.svg SvgGenImage get dartTest => const SvgGenImage( - 'assets/images/icons/dart@test.svg', - size: Size(512.001, 512.001), - ); + 'assets/images/icons/dart@test.svg', + size: Size(512.001, 512.001), + ); /// File path: assets/images/icons/fuchsia.svg SvgGenImage get fuchsia => const SvgGenImage( - 'assets/images/icons/fuchsia.svg', - size: Size(50.0, 50.0), - ); + 'assets/images/icons/fuchsia.svg', + size: Size(50.0, 50.0), + ); /// File path: assets/images/icons/invalid.svg SvgGenImage get invalid => @@ -179,15 +183,15 @@ class $AssetsImagesIconsGen { /// File path: assets/images/icons/kmm.svg SvgGenImage get kmm => const SvgGenImage( - 'assets/images/icons/kmm.svg', - size: Size(755.0, 310.0), - ); + 'assets/images/icons/kmm.svg', + size: Size(755.0, 310.0), + ); /// File path: assets/images/icons/paint.svg SvgGenImage get paint => const SvgGenImage( - 'assets/images/icons/paint.svg', - size: Size(472.0, 392.0), - ); + 'assets/images/icons/paint.svg', + size: Size(472.0, 392.0), + ); /// List of all assets List get values => [dartTest, fuchsia, invalid, kmm, paint]; @@ -201,3 +205,61 @@ abstract final class Assets { static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); static const $PicturesGen pictures = $PicturesGen(); } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart b/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart index 26cbfca9d..8cdac9913 100644 --- a/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart @@ -74,19 +74,19 @@ abstract final class Assets { /// List of all assets static List get values => [ - images_chip1, - images_chip2, - images_chip3_chip3, - images_chip4_chip4, - images_icons_dart_test, - images_icons_fuchsia, - images_icons_kmm, - images_icons_paint, - images_logo, - images_profile_jpg, - images_profile_png, - json_list, - json_map, - pictures_chip5, - ]; + images_chip1, + images_chip2, + images_chip3_chip3, + images_chip4_chip4, + images_icons_dart_test, + images_icons_fuchsia, + images_icons_kmm, + images_icons_paint, + images_logo, + images_profile_jpg, + images_profile_png, + json_list, + json_map, + pictures_chip5, + ]; } diff --git a/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart index 5c5d281f4..16dcda797 100644 --- a/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -40,3 +44,61 @@ class $AssetsImagesIconsGen { abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart b/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart index 7aa194151..0d7bac4a4 100644 --- a/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart @@ -34,12 +34,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } abstract final class Assets { diff --git a/packages/core/test_resources/actual_data/assets_normal.gen.dart b/packages/core/test_resources/actual_data/assets_normal.gen.dart index 6eeb0c571..f547e4d0b 100644 --- a/packages/core/test_resources/actual_data/assets_normal.gen.dart +++ b/packages/core/test_resources/actual_data/assets_normal.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $PicturesGen { const $PicturesGen(); @@ -53,12 +57,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -122,3 +126,61 @@ abstract final class Assets { static const $AssetsJsonGen json = $AssetsJsonGen(); static const $PicturesGen pictures = $PicturesGen(); } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart b/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart index 7aa194151..0d7bac4a4 100644 --- a/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart +++ b/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart @@ -34,12 +34,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } abstract final class Assets { diff --git a/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart b/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart index 7aa194151..0d7bac4a4 100644 --- a/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart @@ -34,12 +34,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } abstract final class Assets { diff --git a/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart b/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart index 373067c75..c1d722171 100644 --- a/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $PicturesGen { const $PicturesGen(); @@ -154,3 +158,61 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart b/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart index 373067c75..c1d722171 100644 --- a/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $PicturesGen { const $PicturesGen(); @@ -154,3 +158,61 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart b/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart index 97d196c97..33b76c912 100644 --- a/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart @@ -9,8 +9,12 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; export 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart' as _svg; +import 'package:vector_graphics/vector_graphics.dart' as _vg; class $PicturesGen { const $PicturesGen(); @@ -54,13 +58,16 @@ class $AssetsImagesGen { AssetGenImage get logo => const AssetGenImage('assets/images/logo.png'); /// File path: assets/images/profile.jpg - AssetGenImage get profileJpg => const AssetGenImage('assets/images/profile.jpg'); + AssetGenImage get profileJpg => + const AssetGenImage('assets/images/profile.jpg'); /// File path: assets/images/profile.png - AssetGenImage get profilePng => const AssetGenImage('assets/images/profile.png'); + AssetGenImage get profilePng => + const AssetGenImage('assets/images/profile.png'); /// List of all assets - List get values => [chip1, chip2, logo, profileJpg, profilePng]; + List get values => + [chip1, chip2, logo, profileJpg, profilePng]; } class $AssetsJsonGen { @@ -100,7 +107,8 @@ class $AssetsImagesChip3Gen { const $AssetsImagesChip3Gen(); /// File path: assets/images/chip3/chip3.jpg - AssetGenImage get chip3 => const AssetGenImage('assets/images/chip3/chip3.jpg'); + AssetGenImage get chip3 => + const AssetGenImage('assets/images/chip3/chip3.jpg'); /// List of all assets List get values => [chip3]; @@ -110,7 +118,8 @@ class $AssetsImagesChip4Gen { const $AssetsImagesChip4Gen(); /// File path: assets/images/chip4/chip4.jpg - AssetGenImage get chip4 => const AssetGenImage('assets/images/chip4/chip4.jpg'); + AssetGenImage get chip4 => + const AssetGenImage('assets/images/chip4/chip4.jpg'); /// List of all assets List get values => [chip4]; @@ -120,10 +129,12 @@ class $AssetsImagesIconsGen { const $AssetsImagesIconsGen(); /// File path: assets/images/icons/dart@test.svg - SvgGenImage get dartTest => const SvgGenImage('assets/images/icons/dart@test.svg'); + SvgGenImage get dartTest => + const SvgGenImage('assets/images/icons/dart@test.svg'); /// File path: assets/images/icons/fuchsia.svg - SvgGenImage get fuchsia => const SvgGenImage('assets/images/icons/fuchsia.svg'); + SvgGenImage get fuchsia => + const SvgGenImage('assets/images/icons/fuchsia.svg'); /// File path: assets/images/icons/kmm.svg SvgGenImage get kmm => const SvgGenImage('assets/images/icons/kmm.svg'); @@ -147,3 +158,61 @@ abstract final class BuildAssets { /// List of all assets static List get values => [changelog]; } + +extension SvgGenImageExtension on SvgGenImage { + _svg.SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + _svg.SvgTheme? theme, + _svg.ColorMapper? colorMapper, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @deprecated Color? color, + @deprecated BlendMode colorBlendMode = BlendMode.srcIn, + @deprecated bool cacheColorFilter = false, + }) { + final _svg.BytesLoader loader; + if (isVecFormat) { + loader = _vg.AssetBytesLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + ); + } else { + loader = _svg.SvgAssetLoader( + path, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + colorMapper: colorMapper, + ); + } + return _svg.SvgPicture( + loader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + cacheColorFilter: cacheColorFilter, + ); + } +} diff --git a/packages/core/test_resources/actual_data/colors_change_output_path.gen.dart b/packages/core/test_resources/actual_data/colors_change_output_path.gen.dart index f37e5ee0c..0a83dca1e 100644 --- a/packages/core/test_resources/actual_data/colors_change_output_path.gen.dart +++ b/packages/core/test_resources/actual_data/colors_change_output_path.gen.dart @@ -28,17 +28,17 @@ abstract final class ColorName { /// 900: #FFB20F0F static const MaterialColor crimsonRed = MaterialColor(0xFFCF2A2A, { - 50: Color(0xFFF9E5E5), - 100: Color(0xFFF1BFBF), - 200: Color(0xFFE79595), - 300: Color(0xFFDD6A6A), - 400: Color(0xFFD64A4A), - 500: Color(0xFFCF2A2A), - 600: Color(0xFFCA2525), - 700: Color(0xFFC31F1F), - 800: Color(0xFFBD1919), - 900: Color(0xFFB20F0F), - }); + 50: Color(0xFFF9E5E5), + 100: Color(0xFFF1BFBF), + 200: Color(0xFFE79595), + 300: Color(0xFFDD6A6A), + 400: Color(0xFFD64A4A), + 500: Color(0xFFCF2A2A), + 600: Color(0xFFCA2525), + 700: Color(0xFFC31F1F), + 800: Color(0xFFBD1919), + 900: Color(0xFFB20F0F), + }); /// Color: #979797 static const Color gray410 = Color(0xFF979797); @@ -62,17 +62,17 @@ abstract final class ColorName { /// 900: #FFCA670E static const MaterialColor yellowOcher = MaterialColor(0xFFDF9527, { - 50: Color(0xFFFBF2E5), - 100: Color(0xFFF5DFBE), - 200: Color(0xFFEFCA93), - 300: Color(0xFFE9B568), - 400: Color(0xFFE4A547), - 500: Color(0xFFDF9527), - 600: Color(0xFFDB8D23), - 700: Color(0xFFD7821D), - 800: Color(0xFFD27817), - 900: Color(0xFFCA670E), - }); + 50: Color(0xFFFBF2E5), + 100: Color(0xFFF5DFBE), + 200: Color(0xFFEFCA93), + 300: Color(0xFFE9B568), + 400: Color(0xFFE4A547), + 500: Color(0xFFDF9527), + 600: Color(0xFFDB8D23), + 700: Color(0xFFD7821D), + 800: Color(0xFFD27817), + 900: Color(0xFFCA670E), + }); /// MaterialAccentColor: /// 100: #FFFFE8E0 @@ -81,9 +81,9 @@ abstract final class ColorName { /// 700: #FFFF9E7A static const MaterialAccentColor yellowOcherAccent = MaterialAccentColor(0xFFFFBCA3, { - 100: Color(0xFFFFE8E0), - 200: Color(0xFFFFBCA3), - 400: Color(0xFFFFA989), - 700: Color(0xFFFF9E7A), - }); + 100: Color(0xFFFFE8E0), + 200: Color(0xFFFFBCA3), + 400: Color(0xFFFFA989), + 700: Color(0xFFFF9E7A), + }); } diff --git a/packages/core/test_resources/actual_data/colors_colors_change_class_name.gen.dart b/packages/core/test_resources/actual_data/colors_colors_change_class_name.gen.dart index 16f67d221..dcce7757f 100644 --- a/packages/core/test_resources/actual_data/colors_colors_change_class_name.gen.dart +++ b/packages/core/test_resources/actual_data/colors_colors_change_class_name.gen.dart @@ -28,17 +28,17 @@ abstract final class MyColorName { /// 900: #FFB20F0F static const MaterialColor crimsonRed = MaterialColor(0xFFCF2A2A, { - 50: Color(0xFFF9E5E5), - 100: Color(0xFFF1BFBF), - 200: Color(0xFFE79595), - 300: Color(0xFFDD6A6A), - 400: Color(0xFFD64A4A), - 500: Color(0xFFCF2A2A), - 600: Color(0xFFCA2525), - 700: Color(0xFFC31F1F), - 800: Color(0xFFBD1919), - 900: Color(0xFFB20F0F), - }); + 50: Color(0xFFF9E5E5), + 100: Color(0xFFF1BFBF), + 200: Color(0xFFE79595), + 300: Color(0xFFDD6A6A), + 400: Color(0xFFD64A4A), + 500: Color(0xFFCF2A2A), + 600: Color(0xFFCA2525), + 700: Color(0xFFC31F1F), + 800: Color(0xFFBD1919), + 900: Color(0xFFB20F0F), + }); /// Color: #979797 static const Color gray410 = Color(0xFF979797); @@ -62,17 +62,17 @@ abstract final class MyColorName { /// 900: #FFCA670E static const MaterialColor yellowOcher = MaterialColor(0xFFDF9527, { - 50: Color(0xFFFBF2E5), - 100: Color(0xFFF5DFBE), - 200: Color(0xFFEFCA93), - 300: Color(0xFFE9B568), - 400: Color(0xFFE4A547), - 500: Color(0xFFDF9527), - 600: Color(0xFFDB8D23), - 700: Color(0xFFD7821D), - 800: Color(0xFFD27817), - 900: Color(0xFFCA670E), - }); + 50: Color(0xFFFBF2E5), + 100: Color(0xFFF5DFBE), + 200: Color(0xFFEFCA93), + 300: Color(0xFFE9B568), + 400: Color(0xFFE4A547), + 500: Color(0xFFDF9527), + 600: Color(0xFFDB8D23), + 700: Color(0xFFD7821D), + 800: Color(0xFFD27817), + 900: Color(0xFFCA670E), + }); /// MaterialAccentColor: /// 100: #FFFFE8E0 @@ -81,9 +81,9 @@ abstract final class MyColorName { /// 700: #FFFF9E7A static const MaterialAccentColor yellowOcherAccent = MaterialAccentColor(0xFFFFBCA3, { - 100: Color(0xFFFFE8E0), - 200: Color(0xFFFFBCA3), - 400: Color(0xFFFFA989), - 700: Color(0xFFFF9E7A), - }); + 100: Color(0xFFFFE8E0), + 200: Color(0xFFFFBCA3), + 400: Color(0xFFFFA989), + 700: Color(0xFFFF9E7A), + }); } diff --git a/packages/core/test_resources/actual_data/colors_normal.gen.dart b/packages/core/test_resources/actual_data/colors_normal.gen.dart index 49ea30773..074b437a9 100644 --- a/packages/core/test_resources/actual_data/colors_normal.gen.dart +++ b/packages/core/test_resources/actual_data/colors_normal.gen.dart @@ -40,17 +40,17 @@ abstract final class ColorName { /// 900: #FFB20F0F static const MaterialColor crimsonRed = MaterialColor(0xFFCF2A2A, { - 50: Color(0xFFF9E5E5), - 100: Color(0xFFF1BFBF), - 200: Color(0xFFE79595), - 300: Color(0xFFDD6A6A), - 400: Color(0xFFD64A4A), - 500: Color(0xFFCF2A2A), - 600: Color(0xFFCA2525), - 700: Color(0xFFC31F1F), - 800: Color(0xFFBD1919), - 900: Color(0xFFB20F0F), - }); + 50: Color(0xFFF9E5E5), + 100: Color(0xFFF1BFBF), + 200: Color(0xFFE79595), + 300: Color(0xFFDD6A6A), + 400: Color(0xFFD64A4A), + 500: Color(0xFFCF2A2A), + 600: Color(0xFFCA2525), + 700: Color(0xFFC31F1F), + 800: Color(0xFFBD1919), + 900: Color(0xFFB20F0F), + }); /// Color: #979797 static const Color gray410 = Color(0xFF979797); @@ -74,17 +74,17 @@ abstract final class ColorName { /// 900: #FFCA670E static const MaterialColor yellowOcher = MaterialColor(0xFFDF9527, { - 50: Color(0xFFFBF2E5), - 100: Color(0xFFF5DFBE), - 200: Color(0xFFEFCA93), - 300: Color(0xFFE9B568), - 400: Color(0xFFE4A547), - 500: Color(0xFFDF9527), - 600: Color(0xFFDB8D23), - 700: Color(0xFFD7821D), - 800: Color(0xFFD27817), - 900: Color(0xFFCA670E), - }); + 50: Color(0xFFFBF2E5), + 100: Color(0xFFF5DFBE), + 200: Color(0xFFEFCA93), + 300: Color(0xFFE9B568), + 400: Color(0xFFE4A547), + 500: Color(0xFFDF9527), + 600: Color(0xFFDB8D23), + 700: Color(0xFFD7821D), + 800: Color(0xFFD27817), + 900: Color(0xFFCA670E), + }); /// MaterialAccentColor: /// 100: #FFFFE8E0 @@ -93,9 +93,9 @@ abstract final class ColorName { /// 700: #FFFF9E7A static const MaterialAccentColor yellowOcherAccent = MaterialAccentColor(0xFFFFBCA3, { - 100: Color(0xFFFFE8E0), - 200: Color(0xFFFFBCA3), - 400: Color(0xFFFFA989), - 700: Color(0xFFFF9E7A), - }); + 100: Color(0xFFFFE8E0), + 200: Color(0xFFFFBCA3), + 400: Color(0xFFFFA989), + 700: Color(0xFFFF9E7A), + }); } diff --git a/packages/core/test_resources/actual_data/colors_only_flutter_gen_value.gen.dart b/packages/core/test_resources/actual_data/colors_only_flutter_gen_value.gen.dart index f37e5ee0c..0a83dca1e 100644 --- a/packages/core/test_resources/actual_data/colors_only_flutter_gen_value.gen.dart +++ b/packages/core/test_resources/actual_data/colors_only_flutter_gen_value.gen.dart @@ -28,17 +28,17 @@ abstract final class ColorName { /// 900: #FFB20F0F static const MaterialColor crimsonRed = MaterialColor(0xFFCF2A2A, { - 50: Color(0xFFF9E5E5), - 100: Color(0xFFF1BFBF), - 200: Color(0xFFE79595), - 300: Color(0xFFDD6A6A), - 400: Color(0xFFD64A4A), - 500: Color(0xFFCF2A2A), - 600: Color(0xFFCA2525), - 700: Color(0xFFC31F1F), - 800: Color(0xFFBD1919), - 900: Color(0xFFB20F0F), - }); + 50: Color(0xFFF9E5E5), + 100: Color(0xFFF1BFBF), + 200: Color(0xFFE79595), + 300: Color(0xFFDD6A6A), + 400: Color(0xFFD64A4A), + 500: Color(0xFFCF2A2A), + 600: Color(0xFFCA2525), + 700: Color(0xFFC31F1F), + 800: Color(0xFFBD1919), + 900: Color(0xFFB20F0F), + }); /// Color: #979797 static const Color gray410 = Color(0xFF979797); @@ -62,17 +62,17 @@ abstract final class ColorName { /// 900: #FFCA670E static const MaterialColor yellowOcher = MaterialColor(0xFFDF9527, { - 50: Color(0xFFFBF2E5), - 100: Color(0xFFF5DFBE), - 200: Color(0xFFEFCA93), - 300: Color(0xFFE9B568), - 400: Color(0xFFE4A547), - 500: Color(0xFFDF9527), - 600: Color(0xFFDB8D23), - 700: Color(0xFFD7821D), - 800: Color(0xFFD27817), - 900: Color(0xFFCA670E), - }); + 50: Color(0xFFFBF2E5), + 100: Color(0xFFF5DFBE), + 200: Color(0xFFEFCA93), + 300: Color(0xFFE9B568), + 400: Color(0xFFE4A547), + 500: Color(0xFFDF9527), + 600: Color(0xFFDB8D23), + 700: Color(0xFFD7821D), + 800: Color(0xFFD27817), + 900: Color(0xFFCA670E), + }); /// MaterialAccentColor: /// 100: #FFFFE8E0 @@ -81,9 +81,9 @@ abstract final class ColorName { /// 700: #FFFF9E7A static const MaterialAccentColor yellowOcherAccent = MaterialAccentColor(0xFFFFBCA3, { - 100: Color(0xFFFFE8E0), - 200: Color(0xFFFFBCA3), - 400: Color(0xFFFFA989), - 700: Color(0xFFFF9E7A), - }); + 100: Color(0xFFFFE8E0), + 200: Color(0xFFFFBCA3), + 400: Color(0xFFFFA989), + 700: Color(0xFFFF9E7A), + }); } diff --git a/packages/core/test_resources/actual_data/colors_wrong_output_path.gen.dart b/packages/core/test_resources/actual_data/colors_wrong_output_path.gen.dart index f37e5ee0c..0a83dca1e 100644 --- a/packages/core/test_resources/actual_data/colors_wrong_output_path.gen.dart +++ b/packages/core/test_resources/actual_data/colors_wrong_output_path.gen.dart @@ -28,17 +28,17 @@ abstract final class ColorName { /// 900: #FFB20F0F static const MaterialColor crimsonRed = MaterialColor(0xFFCF2A2A, { - 50: Color(0xFFF9E5E5), - 100: Color(0xFFF1BFBF), - 200: Color(0xFFE79595), - 300: Color(0xFFDD6A6A), - 400: Color(0xFFD64A4A), - 500: Color(0xFFCF2A2A), - 600: Color(0xFFCA2525), - 700: Color(0xFFC31F1F), - 800: Color(0xFFBD1919), - 900: Color(0xFFB20F0F), - }); + 50: Color(0xFFF9E5E5), + 100: Color(0xFFF1BFBF), + 200: Color(0xFFE79595), + 300: Color(0xFFDD6A6A), + 400: Color(0xFFD64A4A), + 500: Color(0xFFCF2A2A), + 600: Color(0xFFCA2525), + 700: Color(0xFFC31F1F), + 800: Color(0xFFBD1919), + 900: Color(0xFFB20F0F), + }); /// Color: #979797 static const Color gray410 = Color(0xFF979797); @@ -62,17 +62,17 @@ abstract final class ColorName { /// 900: #FFCA670E static const MaterialColor yellowOcher = MaterialColor(0xFFDF9527, { - 50: Color(0xFFFBF2E5), - 100: Color(0xFFF5DFBE), - 200: Color(0xFFEFCA93), - 300: Color(0xFFE9B568), - 400: Color(0xFFE4A547), - 500: Color(0xFFDF9527), - 600: Color(0xFFDB8D23), - 700: Color(0xFFD7821D), - 800: Color(0xFFD27817), - 900: Color(0xFFCA670E), - }); + 50: Color(0xFFFBF2E5), + 100: Color(0xFFF5DFBE), + 200: Color(0xFFEFCA93), + 300: Color(0xFFE9B568), + 400: Color(0xFFE4A547), + 500: Color(0xFFDF9527), + 600: Color(0xFFDB8D23), + 700: Color(0xFFD7821D), + 800: Color(0xFFD27817), + 900: Color(0xFFCA670E), + }); /// MaterialAccentColor: /// 100: #FFFFE8E0 @@ -81,9 +81,9 @@ abstract final class ColorName { /// 700: #FFFF9E7A static const MaterialAccentColor yellowOcherAccent = MaterialAccentColor(0xFFFFBCA3, { - 100: Color(0xFFFFE8E0), - 200: Color(0xFFFFBCA3), - 400: Color(0xFFFFA989), - 700: Color(0xFFFF9E7A), - }); + 100: Color(0xFFFFE8E0), + 200: Color(0xFFFFBCA3), + 400: Color(0xFFFFA989), + 700: Color(0xFFFF9E7A), + }); } diff --git a/packages/flutter_gen_interface/lib/flutter_gen_interface.dart b/packages/flutter_gen_interface/lib/flutter_gen_interface.dart index 19f3aa2d0..4c7d5d643 100644 --- a/packages/flutter_gen_interface/lib/flutter_gen_interface.dart +++ b/packages/flutter_gen_interface/lib/flutter_gen_interface.dart @@ -1,6 +1,4 @@ import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:vector_graphics/vector_graphics.dart'; class AssetGenImage { const AssetGenImage( @@ -120,61 +118,10 @@ class SvgGenImage { final bool _isVecFormat; final String? package; - SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - SvgTheme? theme, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @Deprecated('Use colorFilter instead') Color? color, - @Deprecated('Use colorFilter instead') - BlendMode colorBlendMode = BlendMode.srcIn, - @Deprecated('This no longer does anything') bool cacheColorFilter = false, - }) { - final bytesLoader = _isVecFormat - ? AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package ?? this.package, - ) - : SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package ?? this.package, - theme: theme, - ); - return SvgPicture( - bytesLoader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - // ignore: deprecated_member_use - cacheColorFilter: cacheColorFilter, - ); - } - String get path => _assetName; String get keyName => package == null ? _assetName : 'packages/$package/$_assetName'; + + bool get isVecFormat => _isVecFormat; } diff --git a/packages/flutter_gen_interface/pubspec.yaml b/packages/flutter_gen_interface/pubspec.yaml index 05d2ed040..c958235e0 100644 --- a/packages/flutter_gen_interface/pubspec.yaml +++ b/packages/flutter_gen_interface/pubspec.yaml @@ -13,10 +13,9 @@ environment: dependencies: flutter: sdk: flutter - flutter_svg: '>=2.0.0 <3.0.0' - vector_graphics: '>=1.1.9 <2.0.0' dev_dependencies: flutter_test: sdk: flutter lints: any # Ignoring the version to allow editing across SDK versions. + diff --git a/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart b/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart index 6ddda1eaa..3d684dc2a 100644 --- a/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart +++ b/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart @@ -1,8 +1,6 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_gen_interface/flutter_gen_interface.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:vector_graphics/vector_graphics.dart'; void main() { group('AssetGenImage', () { @@ -38,32 +36,38 @@ void main() { }); group('SvgGenImage', () { - test('properties and keyName', () { - const svg = SvgGenImage('assets/icon.svg'); + test('properties and keyName for standard svg', () { + const svg = SvgGenImage( + 'assets/icon.svg', + size: Size(24, 24), + flavors: {'free'}, + ); expect(svg.path, 'assets/icon.svg'); expect(svg.keyName, 'assets/icon.svg'); + expect(svg.size, const Size(24, 24)); + expect(svg.flavors, {'free'}); + expect(svg.isVecFormat, isFalse); + expect(svg.package, isNull); const packageSvg = SvgGenImage('assets/icon.svg', package: 'pkg'); expect(packageSvg.path, 'assets/icon.svg'); expect(packageSvg.keyName, r'packages/pkg/assets/icon.svg'); + expect(packageSvg.package, 'pkg'); }); - testWidgets('svg returns SvgPicture widget', (tester) async { - const svg = SvgGenImage('assets/icon.svg'); - final widget = svg.svg(); - expect(widget.bytesLoader, isA()); - final loader = widget.bytesLoader as SvgAssetLoader; - expect(loader.assetName, 'assets/icon.svg'); - expect(loader.packageName, isNull); - }); - - testWidgets('vec returns SvgPicture widget with AssetBytesLoader', (tester) async { - const vec = SvgGenImage.vec('assets/icon.vec'); - final widget = vec.svg(); - expect(widget.bytesLoader, isA()); - final loader = widget.bytesLoader as AssetBytesLoader; - expect(loader.assetName, 'assets/icon.vec'); - expect(loader.packageName, isNull); + test('properties and keyName for vec format', () { + const vec = SvgGenImage.vec( + 'assets/icon.vec', + size: Size(32, 32), + flavors: {'premium'}, + package: 'pkg', + ); + expect(vec.path, 'assets/icon.vec'); + expect(vec.keyName, r'packages/pkg/assets/icon.vec'); + expect(vec.size, const Size(32, 32)); + expect(vec.flavors, {'premium'}); + expect(vec.isVecFormat, isTrue); + expect(vec.package, 'pkg'); }); }); }