diff --git a/CHANGELOG.md b/CHANGELOG.md index 351edeac9..6e953cb0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.16.0 + +**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. + ## 5.15.0 **Feature** 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/melos.yaml b/melos.yaml index af410db08..b59b383ef 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 @@ -136,6 +137,7 @@ scripts: - flutter_gen - flutter_gen_core - flutter_gen_runner + - flutter_gen_interface publish:dry: run: dart pub publish --dry-run @@ -147,3 +149,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..dd4ad5128 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,17 @@ 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..ba1cea69d 100644 --- a/packages/core/lib/generators/integrations/image_integration.dart +++ b/packages/core/lib/generators/integrations/image_integration.dart @@ -26,109 +26,13 @@ class ImageIntegration extends Integration { @override List get requiredImports => const [ - Import('package:flutter/widgets.dart'), + 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 +61,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..dbdba0d0e 100644 --- a/packages/core/lib/generators/integrations/svg_integration.dart +++ b/packages/core/lib/generators/integrations/svg_integration.dart @@ -10,10 +10,9 @@ 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'), Import('package:flutter/widgets.dart'), Import('package:flutter/services.dart'), Import('package:flutter_svg/flutter_svg.dart', alias: '_svg'), @@ -23,31 +22,13 @@ class SvgIntegration extends Integration { @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';" : ''} - + String get _classDefinition => + '''extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, AssetBundle? bundle, - ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageExpression, + ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package, double? width, double? height, BoxFit fit = BoxFit.contain, @@ -65,17 +46,17 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -97,10 +78,6 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} cacheColorFilter: cacheColorFilter, ); } - - String get path => _assetName; - - String get keyName => ${isPackage ? '\'packages/$packageName/\$_assetName\'' : '_assetName'}; }'''; @override @@ -127,7 +104,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..1f3fc65f3 100644 --- a/packages/core/test/assets_gen_integrations_test.dart +++ b/packages/core/test/assets_gen_integrations_test.dart @@ -174,20 +174,31 @@ 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( - 'String? package = package,', + "@Deprecated('Do not specify package for a generated library asset')", ), isTrue, ); expect( - integrationWithPackage.classOutput.contains( - "static const String package = 'package_name';", + integrationWithPackage.classInstantiate( + AssetType( + rootPath: resPath, + path: 'assets/path/dog.svg', + flavors: {}, + transformers: {}, + ), ), - isTrue, + "SvgGenImage('assets/path/dog.svg', package: 'package_name',)", ); }); 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..c1d722171 100644 --- a/packages/core/test_resources/actual_data/assets_assets.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets.gen.dart @@ -11,6 +11,8 @@ 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; @@ -157,119 +159,7 @@ abstract final class 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -292,17 +182,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -325,8 +215,4 @@ class SvgGenImage { 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..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 @@ -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 @@ -72,107 +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, - ]; -} - -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; + 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 dcc0bdc6d..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 @@ -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(); @@ -33,102 +34,14 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } 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..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 @@ -11,6 +11,8 @@ 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; @@ -79,12 +81,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -129,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]; @@ -216,106 +218,7 @@ abstract final class 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -338,17 +241,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -365,15 +268,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? + 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..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 @@ -11,6 +11,8 @@ 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; @@ -77,106 +79,7 @@ abstract final class Assets { 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -199,17 +102,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -226,15 +129,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? + 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..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 @@ -11,6 +11,8 @@ 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; @@ -46,7 +48,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 +62,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'; @@ -80,121 +82,13 @@ abstract final class Assets { 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'; - +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 = package, + String? package, double? width, double? height, BoxFit fit = BoxFit.contain, @@ -212,17 +106,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -239,15 +133,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? + 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..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 @@ -11,6 +11,8 @@ 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; @@ -65,12 +67,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -162,106 +164,7 @@ abstract final class 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -284,17 +187,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -311,15 +214,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? + 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_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 751ba7516..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 @@ -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(); @@ -52,12 +53,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -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..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 @@ -11,6 +11,8 @@ 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; @@ -40,7 +42,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 +53,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]; @@ -68,121 +70,13 @@ abstract final class Assets { 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'; - +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 = package, + String? package, double? width, double? height, BoxFit fit = BoxFit.contain, @@ -200,17 +94,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -227,15 +121,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? + 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..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 @@ -11,6 +11,8 @@ 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; @@ -29,7 +31,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 +42,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]; @@ -56,121 +58,13 @@ 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'; - +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 = package, + String? package, double? width, double? height, BoxFit fit = BoxFit.contain, @@ -188,17 +82,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -215,15 +109,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? + 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..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 @@ -11,6 +11,8 @@ 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; @@ -43,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'); @@ -61,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 => @@ -75,12 +77,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -121,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]; @@ -139,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]; @@ -152,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]; @@ -165,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 => @@ -181,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]; @@ -204,106 +206,7 @@ abstract final class Assets { 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -326,17 +229,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -353,15 +256,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? + 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..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 @@ -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 @@ -73,107 +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, - ]; -} - -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; + 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 351ef6d8f..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 @@ -11,6 +11,8 @@ 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; @@ -43,18 +45,7 @@ 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -77,17 +68,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -104,15 +95,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? + 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..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 @@ -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(); @@ -33,102 +34,14 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } 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..f547e4d0b 100644 --- a/packages/core/test_resources/actual_data/assets_normal.gen.dart +++ b/packages/core/test_resources/actual_data/assets_normal.gen.dart @@ -11,6 +11,8 @@ 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; @@ -55,12 +57,12 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -125,106 +127,7 @@ abstract final class Assets { 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -247,17 +150,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -274,15 +177,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? + 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..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 @@ -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(); @@ -33,102 +34,14 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } 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..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 @@ -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(); @@ -33,102 +34,14 @@ class $AssetsImagesGen { /// List of all assets List get values => [ - chip1, - chip2, - logo, - profileJpg, - profilePng, - ]; + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } 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..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 @@ -11,6 +11,8 @@ 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; @@ -157,119 +159,7 @@ abstract final class 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -292,17 +182,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -325,8 +215,4 @@ class SvgGenImage { 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..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 @@ -11,6 +11,8 @@ 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; @@ -157,119 +159,7 @@ abstract final class 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -292,17 +182,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -325,8 +215,4 @@ class SvgGenImage { 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..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 @@ -11,6 +11,8 @@ 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; @@ -56,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 { @@ -102,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]; @@ -112,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]; @@ -122,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'); @@ -150,119 +159,7 @@ abstract final class BuildAssets { 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; - +extension SvgGenImageExtension on SvgGenImage { _svg.SvgPicture svg({ Key? key, bool matchTextDirection = false, @@ -285,17 +182,17 @@ class SvgGenImage { @deprecated bool cacheColorFilter = false, }) { final _svg.BytesLoader loader; - if (_isVecFormat) { + if (isVecFormat) { loader = _vg.AssetBytesLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, ); } else { loader = _svg.SvgAssetLoader( - _assetName, + path, assetBundle: bundle, - packageName: package, + packageName: package ?? this.package, theme: theme, colorMapper: colorMapper, ); @@ -312,13 +209,10 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + 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/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/.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..4c7d5d643 --- /dev/null +++ b/packages/flutter_gen_interface/lib/flutter_gen_interface.dart @@ -0,0 +1,127 @@ +import 'package:flutter/widgets.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; + + 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 new file mode 100644 index 000000000..c958235e0 --- /dev/null +++ b/packages/flutter_gen_interface/pubspec.yaml @@ -0,0 +1,21 @@ +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 + +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..3d684dc2a --- /dev/null +++ b/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart @@ -0,0 +1,73 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_test/flutter_test.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 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'); + }); + + 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'); + }); + }); +}