diff --git a/CHANGELOG.md b/CHANGELOG.md index af39ecce..5e500ecb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 5.15.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.14.1 **Development** diff --git a/melos.yaml b/melos.yaml index 7e262c15..36c25389 100644 --- a/melos.yaml +++ b/melos.yaml @@ -4,6 +4,7 @@ packages: - packages/command - packages/core - packages/runner + - packages/flutter_gen_interface - examples/example - examples/example_resources - examples/example_workspace @@ -132,6 +133,7 @@ scripts: - flutter_gen - flutter_gen_core - flutter_gen_runner + - flutter_gen_interface publish:dry: run: dart pub publish --dry-run @@ -143,3 +145,4 @@ scripts: - flutter_gen - flutter_gen_core - flutter_gen_runner + - flutter_gen_interface diff --git a/packages/core/lib/generators/assets_generator.dart b/packages/core/lib/generators/assets_generator.dart index f7dfb204..716602cd 100644 --- a/packages/core/lib/generators/assets_generator.dart +++ b/packages/core/lib/generators/assets_generator.dart @@ -77,7 +77,6 @@ Future generateAssets( 'The value of "flutter/assets:" is incorrect.', ); } - final integrations = [ if (config.flutterGen.integrations.image) ImageIntegration( @@ -165,7 +164,15 @@ Future generateAssets( final importsBuffer = StringBuffer(); for (final e in imports.sorted((a, b) => a.import.compareTo(b.import))) { - importsBuffer.writeln(import(e)); + if (e.import == + 'package:flutter_gen_interface/flutter_gen_interface.dart') { + importsBuffer.writeln( + 'import \'package:flutter_gen_interface/flutter_gen_interface.dart\';'); + importsBuffer.writeln( + 'export \'package:flutter_gen_interface/flutter_gen_interface.dart\';'); + } else { + importsBuffer.writeln(import(e)); + } } final buffer = StringBuffer(); diff --git a/packages/core/lib/generators/integrations/image_integration.dart b/packages/core/lib/generators/integrations/image_integration.dart index ed5a73e9..d24b654d 100644 --- a/packages/core/lib/generators/integrations/image_integration.dart +++ b/packages/core/lib/generators/integrations/image_integration.dart @@ -25,110 +25,13 @@ class ImageIntegration extends Integration { isPackage ? "'packages/$packageName/\$_assetName'" : '_assetName'; @override - List get requiredImports => const [ - Import('package:flutter/widgets.dart'), + List get requiredImports => [ + const Import( + 'package:flutter_gen_interface/flutter_gen_interface.dart'), ]; @override - String get classOutput => _classDefinition; - - String get _classDefinition => '''class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - -${isPackage ? "\n static const String package = '$packageName';" : ''} - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageParameter, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageParameter, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => $keyName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} -'''; + String get classOutput => ''; @override String get className => 'AssetGenImage'; @@ -157,7 +60,10 @@ class AssetGenImageAnimation { final flavors = asset.flavors.map((e) => '\'$e\'').join(', '); buffer.write(flavors); buffer.write('}'); - buffer.write(','); // Better formatting. + if (!isPackage) buffer.write(','); // Better formatting. + } + if (isPackage) { + buffer.write(', package: \'$packageName\','); } buffer.write(')'); return buffer.toString(); diff --git a/packages/core/lib/generators/integrations/svg_integration.dart b/packages/core/lib/generators/integrations/svg_integration.dart index 86919d88..3d92d025 100644 --- a/packages/core/lib/generators/integrations/svg_integration.dart +++ b/packages/core/lib/generators/integrations/svg_integration.dart @@ -13,95 +13,13 @@ class SvgIntegration extends Integration { String get packageExpression => isPackage ? ' = package' : ''; @override - List get requiredImports => const [ - Import('package:flutter/widgets.dart'), - Import('package:flutter/services.dart'), - Import('package:flutter_svg/flutter_svg.dart', alias: '_svg'), - Import('package:vector_graphics/vector_graphics.dart', alias: '_vg'), + List get requiredImports => [ + const Import( + 'package:flutter_gen_interface/flutter_gen_interface.dart'), ]; @override - String get classOutput => _classDefinition; - - String get _classDefinition => '''class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - -${isPackage ? "\n static const String package = '$packageName';" : ''} - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageExpression, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => ${isPackage ? '\'packages/$packageName/\$_assetName\'' : '_assetName'}; -}'''; + String get classOutput => ''; @override String get className => 'SvgGenImage'; @@ -127,7 +45,10 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} final flavors = asset.flavors.map((e) => '\'$e\'').join(', '); buffer.write(flavors); buffer.write('}'); - buffer.write(','); // Better formatting. + if (!isPackage) buffer.write(','); // Better formatting. + } + if (isPackage) { + buffer.write(', package: \'$packageName\','); } buffer.write(')'); return buffer.toString(); diff --git a/packages/core/test/assets_gen_integrations_test.dart b/packages/core/test/assets_gen_integrations_test.dart index e07560f3..bd352eb8 100644 --- a/packages/core/test/assets_gen_integrations_test.dart +++ b/packages/core/test/assets_gen_integrations_test.dart @@ -174,21 +174,6 @@ void main() { isFalse, ); expect(integration.isConstConstructor, isTrue); - expect(integration.classOutput.contains('String? package,'), isTrue); - - final integrationWithPackage = SvgIntegration('package_name'); - expect( - integrationWithPackage.classOutput.contains( - 'String? package = package,', - ), - isTrue, - ); - expect( - integrationWithPackage.classOutput.contains( - "static const String package = 'package_name';", - ), - isTrue, - ); }); test('Assets with Rive integrations on pubspec.yaml', () async { diff --git a/packages/core/test/assets_gen_test.dart b/packages/core/test/assets_gen_test.dart index 38ab0912..9d30c850 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 8adde2e9..373067c7 100644 --- a/packages/core/test_resources/actual_data/assets_assets.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -156,177 +154,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart b/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart index 0938c902..47c2f069 100644 --- a/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_camel_case.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; abstract final class Assets { /// File path: assets/images/chip1.jpg @@ -88,91 +89,3 @@ abstract final class Assets { picturesChip5, ]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart b/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart index dcc0bdc6..9a84982a 100644 --- a/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_change_class_name.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -44,91 +45,3 @@ class $AssetsImagesGen { abstract final class MyAssets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart b/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart index e6b01d08..472f0bdc 100644 --- a/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_deferred_components.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -215,165 +213,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart b/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart index 3a7e669c..e1e2efeb 100644 --- a/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_directory_path.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -76,165 +74,3 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart b/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart index bc03f71d..42ffff65 100644 --- a/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_directory_path_with_package_parameter.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -46,7 +44,7 @@ class $AssetsImagesChip3Gen { /// File path: assets/images/chip3/chip3.jpg AssetGenImage get chip3 => - const AssetGenImage('assets/images/chip3/chip3.jpg'); + const AssetGenImage('assets/images/chip3/chip3.jpg', package: 'test'); /// Directory path: packages/test/assets/images/chip3 String get path => 'packages/test/assets/images/chip3'; @@ -60,11 +58,11 @@ class $AssetsImagesIconsGen { /// File path: assets/images/icons/dart@test.svg SvgGenImage get dartTest => - const SvgGenImage('assets/images/icons/dart@test.svg'); + const SvgGenImage('assets/images/icons/dart@test.svg', package: 'test'); /// File path: assets/images/icons/fuchsia.svg SvgGenImage get fuchsia => - const SvgGenImage('assets/images/icons/fuchsia.svg'); + const SvgGenImage('assets/images/icons/fuchsia.svg', package: 'test'); /// Directory path: packages/test/assets/images/icons String get path => 'packages/test/assets/images/icons'; @@ -79,175 +77,3 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - static const String package = 'test'; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - }) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - static const String package = 'test'; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_exclude_files.gen.dart b/packages/core/test_resources/actual_data/assets_assets_exclude_files.gen.dart index 10386b38..176bacaf 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 73fc6263..0d6bdf2d 100644 --- a/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_flavored.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -161,165 +159,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart index 751ba751..34f634e5 100644 --- a/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_no_integrations.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -119,91 +120,3 @@ abstract final class Assets { static const $AssetsJsonGen json = $AssetsJsonGen(); static const $PicturesGen pictures = $PicturesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart b/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart index 25618431..996a8ce4 100644 --- a/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_package_parameter.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -40,7 +38,7 @@ class $AssetsImagesChip3Gen { /// File path: assets/images/chip3/chip3.jpg AssetGenImage get chip3 => - const AssetGenImage('assets/images/chip3/chip3.jpg'); + const AssetGenImage('assets/images/chip3/chip3.jpg', package: 'test'); /// List of all assets List get values => [chip3]; @@ -51,11 +49,11 @@ class $AssetsImagesIconsGen { /// File path: assets/images/icons/dart@test.svg SvgGenImage get dartTest => - const SvgGenImage('assets/images/icons/dart@test.svg'); + const SvgGenImage('assets/images/icons/dart@test.svg', package: 'test'); /// File path: assets/images/icons/fuchsia.svg SvgGenImage get fuchsia => - const SvgGenImage('assets/images/icons/fuchsia.svg'); + const SvgGenImage('assets/images/icons/fuchsia.svg', package: 'test'); /// List of all assets List get values => [dartTest, fuchsia]; @@ -67,175 +65,3 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - static const String package = 'test'; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - }) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - static const String package = 'test'; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart b/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart index 582ea749..0d06b196 100644 --- a/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_package_parameter_disable_null_safety.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -29,7 +27,7 @@ class $AssetsImagesChip3Gen { /// File path: assets/images/chip3/chip3.jpg AssetGenImage get chip3 => - const AssetGenImage('assets/images/chip3/chip3.jpg'); + const AssetGenImage('assets/images/chip3/chip3.jpg', package: 'test'); /// List of all assets List get values => [chip3]; @@ -40,11 +38,11 @@ class $AssetsImagesIconsGen { /// File path: assets/images/icons/dart@test.svg SvgGenImage get dartTest => - const SvgGenImage('assets/images/icons/dart@test.svg'); + const SvgGenImage('assets/images/icons/dart@test.svg', package: 'test'); /// File path: assets/images/icons/fuchsia.svg SvgGenImage get fuchsia => - const SvgGenImage('assets/images/icons/fuchsia.svg'); + const SvgGenImage('assets/images/icons/fuchsia.svg', package: 'test'); /// List of all assets List get values => [dartTest, fuchsia]; @@ -55,175 +53,3 @@ abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - static const String package = 'test'; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - }) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - static const String package = 'test'; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - @Deprecated('Do not specify package for a generated library asset') - String? package = package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => 'packages/test/$_assetName'; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart b/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart index 451729d2..8235ad22 100644 --- a/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_parse_metadata.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -203,165 +201,3 @@ abstract final class Assets { static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); static const $PicturesGen pictures = $PicturesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart b/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart index e985f616..26cbfca9 100644 --- a/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_snake_case.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; abstract final class Assets { /// File path: assets/images/chip1.jpg @@ -89,91 +90,3 @@ abstract final class Assets { pictures_chip5, ]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart index 351ef6d8..5c5d281f 100644 --- a/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_assets_svg_integrations.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -42,77 +40,3 @@ class $AssetsImagesIconsGen { abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart b/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart index c37ee581..7aa19415 100644 --- a/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_change_output_path.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -44,91 +45,3 @@ class $AssetsImagesGen { abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_normal.gen.dart b/packages/core/test_resources/actual_data/assets_normal.gen.dart index 415b3544..6eeb0c57 100644 --- a/packages/core/test_resources/actual_data/assets_normal.gen.dart +++ b/packages/core/test_resources/actual_data/assets_normal.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -124,165 +122,3 @@ abstract final class Assets { static const $AssetsJsonGen json = $AssetsJsonGen(); static const $PicturesGen pictures = $PicturesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = false; - - const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) - : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: - colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart b/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart index c37ee581..7aa19415 100644 --- a/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart +++ b/packages/core/test_resources/actual_data/assets_only_flutter_value.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -44,91 +45,3 @@ class $AssetsImagesGen { abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart b/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart index c37ee581..7aa19415 100644 --- a/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_wrong_output_path.gen.dart @@ -9,7 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); @@ -44,91 +45,3 @@ class $AssetsImagesGen { abstract final class Assets { static const $AssetsImagesGen images = $AssetsImagesGen(); } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({AssetBundle? bundle, String? package}) { - return AssetImage(_assetName, bundle: bundle, package: package); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} diff --git a/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart b/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart index 8adde2e9..373067c7 100644 --- a/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets_build_assets.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -156,177 +154,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart b/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart index 8adde2e9..373067c7 100644 --- a/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets_build_empty.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -156,177 +154,3 @@ abstract final class Assets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? - (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart b/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart index 1e6da27b..97d196c9 100644 --- a/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets_build_runner_assets.gen.dart @@ -9,10 +9,8 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart' as _svg; -import 'package:vector_graphics/vector_graphics.dart' as _vg; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +export 'package:flutter_gen_interface/flutter_gen_interface.dart'; class $PicturesGen { const $PicturesGen(); @@ -149,176 +147,3 @@ abstract final class BuildAssets { /// List of all assets static List get values => [changelog]; } - -class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - this.animation, - }); - - final String _assetName; - - final Size? size; - final Set flavors; - final AssetGenImageAnimation? animation; - - Image image({ - Key? key, - AssetBundle? bundle, - ImageFrameBuilder? frameBuilder, - ImageErrorWidgetBuilder? errorBuilder, - String? semanticLabel, - bool excludeFromSemantics = false, - double? scale, - double? width, - double? height, - Color? color, - Animation? opacity, - BlendMode? colorBlendMode, - BoxFit? fit, - AlignmentGeometry alignment = Alignment.center, - ImageRepeat repeat = ImageRepeat.noRepeat, - Rect? centerSlice, - bool matchTextDirection = false, - bool gaplessPlayback = true, - bool isAntiAlias = false, - String? package, - FilterQuality filterQuality = FilterQuality.medium, - int? cacheWidth, - int? cacheHeight, - }) { - return Image.asset( - _assetName, - key: key, - bundle: bundle, - frameBuilder: frameBuilder, - errorBuilder: errorBuilder, - semanticLabel: semanticLabel, - excludeFromSemantics: excludeFromSemantics, - scale: scale, - width: width, - height: height, - color: color, - opacity: opacity, - colorBlendMode: colorBlendMode, - fit: fit, - alignment: alignment, - repeat: repeat, - centerSlice: centerSlice, - matchTextDirection: matchTextDirection, - gaplessPlayback: gaplessPlayback, - isAntiAlias: isAntiAlias, - package: package, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - ); - } - - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} - -class AssetGenImageAnimation { - const AssetGenImageAnimation({ - required this.isAnimation, - required this.duration, - required this.frames, - }); - - final bool isAnimation; - final Duration duration; - final int frames; -} - -class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; - - final String _assetName; - final Size? size; - final Set flavors; - final bool _isVecFormat; - - _svg.SvgPicture svg({ - Key? key, - bool matchTextDirection = false, - AssetBundle? bundle, - String? package, - double? width, - double? height, - BoxFit fit = BoxFit.contain, - AlignmentGeometry alignment = Alignment.center, - bool allowDrawingOutsideViewBox = false, - WidgetBuilder? placeholderBuilder, - String? semanticsLabel, - bool excludeFromSemantics = false, - _svg.SvgTheme? theme, - _svg.ColorMapper? colorMapper, - ColorFilter? colorFilter, - Clip clipBehavior = Clip.hardEdge, - @deprecated Color? color, - @deprecated BlendMode colorBlendMode = BlendMode.srcIn, - @deprecated bool cacheColorFilter = false, - }) { - final _svg.BytesLoader loader; - if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); - } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - colorMapper: colorMapper, - ); - } - return _svg.SvgPicture( - loader, - key: key, - matchTextDirection: matchTextDirection, - width: width, - height: height, - fit: fit, - alignment: alignment, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), - clipBehavior: clipBehavior, - cacheColorFilter: cacheColorFilter, - ); - } - - String get path => _assetName; - - String get keyName => _assetName; -} diff --git a/packages/flutter_gen_interface/.gitignore b/packages/flutter_gen_interface/.gitignore new file mode 100644 index 00000000..dd5eb989 --- /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 00000000..28c719b7 --- /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 00000000..699cc9e7 --- /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 00000000..30cff740 --- /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 00000000..fe840054 --- /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 00000000..fac60e24 --- /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 00000000..19f3aa2d --- /dev/null +++ b/packages/flutter_gen_interface/lib/flutter_gen_interface.dart @@ -0,0 +1,180 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:vector_graphics/vector_graphics.dart'; + +class AssetGenImage { + const AssetGenImage( + this._assetName, { + this.size, + this.flavors = const {}, + this.package, + this.animation, + }); + + final String _assetName; + final String? package; + final Size? size; + final Set flavors; + final AssetGenImageAnimation? animation; + + Image image({ + Key? key, + AssetBundle? bundle, + ImageFrameBuilder? frameBuilder, + ImageErrorWidgetBuilder? errorBuilder, + String? semanticLabel, + bool excludeFromSemantics = false, + double? scale, + double? width, + double? height, + Color? color, + Animation? opacity, + BlendMode? colorBlendMode, + BoxFit? fit, + AlignmentGeometry alignment = Alignment.center, + ImageRepeat repeat = ImageRepeat.noRepeat, + Rect? centerSlice, + bool matchTextDirection = false, + bool gaplessPlayback = true, + bool isAntiAlias = false, + String? package, + FilterQuality filterQuality = FilterQuality.medium, + int? cacheWidth, + int? cacheHeight, + }) { + return Image.asset( + _assetName, + key: key, + bundle: bundle, + frameBuilder: frameBuilder, + errorBuilder: errorBuilder, + semanticLabel: semanticLabel, + excludeFromSemantics: excludeFromSemantics, + scale: scale, + width: width, + height: height, + color: color, + opacity: opacity, + colorBlendMode: colorBlendMode, + fit: fit, + alignment: alignment, + repeat: repeat, + centerSlice: centerSlice, + matchTextDirection: matchTextDirection, + gaplessPlayback: gaplessPlayback, + isAntiAlias: isAntiAlias, + package: package ?? this.package, + filterQuality: filterQuality, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + ); + } + + ImageProvider provider({ + AssetBundle? bundle, + String? package, + }) { + return AssetImage( + _assetName, + bundle: bundle, + package: package ?? this.package, + ); + } + + String get path => _assetName; + + String get keyName => + package == null ? _assetName : 'packages/$package/$_assetName'; +} + +class AssetGenImageAnimation { + const AssetGenImageAnimation({ + required this.isAnimation, + required this.duration, + required this.frames, + }); + + final bool isAnimation; + final Duration duration; + final int frames; +} + +class SvgGenImage { + const SvgGenImage( + this._assetName, { + this.size, + this.flavors = const {}, + this.package, + }) : _isVecFormat = false; + + const SvgGenImage.vec( + this._assetName, { + this.size, + this.flavors = const {}, + this.package, + }) : _isVecFormat = true; + + final String _assetName; + final Size? size; + final Set flavors; + final bool _isVecFormat; + final String? package; + + SvgPicture svg({ + Key? key, + bool matchTextDirection = false, + AssetBundle? bundle, + String? package, + double? width, + double? height, + BoxFit fit = BoxFit.contain, + AlignmentGeometry alignment = Alignment.center, + bool allowDrawingOutsideViewBox = false, + WidgetBuilder? placeholderBuilder, + String? semanticsLabel, + bool excludeFromSemantics = false, + SvgTheme? theme, + ColorFilter? colorFilter, + Clip clipBehavior = Clip.hardEdge, + @Deprecated('Use colorFilter instead') Color? color, + @Deprecated('Use colorFilter instead') + BlendMode colorBlendMode = BlendMode.srcIn, + @Deprecated('This no longer does anything') bool cacheColorFilter = false, + }) { + final bytesLoader = _isVecFormat + ? AssetBytesLoader( + _assetName, + assetBundle: bundle, + packageName: package ?? this.package, + ) + : SvgAssetLoader( + _assetName, + assetBundle: bundle, + packageName: package ?? this.package, + theme: theme, + ); + return SvgPicture( + bytesLoader, + key: key, + matchTextDirection: matchTextDirection, + width: width, + height: height, + fit: fit, + alignment: alignment, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + colorFilter: colorFilter ?? + (color == null ? null : ColorFilter.mode(color, colorBlendMode)), + clipBehavior: clipBehavior, + // ignore: deprecated_member_use + cacheColorFilter: cacheColorFilter, + ); + } + + String get path => _assetName; + + String get keyName => + package == null ? _assetName : 'packages/$package/$_assetName'; +} diff --git a/packages/flutter_gen_interface/pubspec.yaml b/packages/flutter_gen_interface/pubspec.yaml new file mode 100644 index 00000000..05d2ed04 --- /dev/null +++ b/packages/flutter_gen_interface/pubspec.yaml @@ -0,0 +1,22 @@ +name: flutter_gen_interface +description: "A package exposing the XXXGenImage classes used by flutter_gen so modular packages can share the same inheritance tree." +version: 1.0.0 +homepage: https://github.com/FlutterGen/flutter_gen +repository: https://github.com/FlutterGen/flutter_gen/tree/main/packages/flutter_gen_interface +documentation: https://github.com/FlutterGen/flutter_gen +issue_tracker: https://github.com/FlutterGen/flutter_gen/issues + +environment: + sdk: '>=3.0.0 <4.0.0' + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + flutter_svg: '>=2.0.0 <3.0.0' + vector_graphics: '>=1.1.9 <2.0.0' + +dev_dependencies: + flutter_test: + sdk: flutter + lints: any # Ignoring the version to allow editing across SDK versions. diff --git a/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart b/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart new file mode 100644 index 00000000..6ddda1ea --- /dev/null +++ b/packages/flutter_gen_interface/test/flutter_gen_interface_test.dart @@ -0,0 +1,69 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_gen_interface/flutter_gen_interface.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:vector_graphics/vector_graphics.dart'; + +void main() { + group('AssetGenImage', () { + test('properties and keyName', () { + const image = AssetGenImage('assets/image.png'); + expect(image.path, 'assets/image.png'); + expect(image.keyName, 'assets/image.png'); + + const packageImage = AssetGenImage('assets/image.png', package: 'pkg'); + expect(packageImage.path, 'assets/image.png'); + expect(packageImage.keyName, r'packages/pkg/assets/image.png'); + }); + + testWidgets('provider returns AssetImage', (tester) async { + const image = AssetGenImage('assets/image.png'); + final provider = image.provider() as AssetImage; + expect(provider.assetName, 'assets/image.png'); + expect(provider.package, isNull); + + const packageImage = AssetGenImage('assets/image.png', package: 'pkg'); + final packageProvider = packageImage.provider() as AssetImage; + expect(packageProvider.assetName, 'assets/image.png'); + expect(packageProvider.package, 'pkg'); + }); + + testWidgets('image returns Image widget', (tester) async { + const image = AssetGenImage('assets/image.png'); + final widget = image.image(); + expect(widget.image, isA()); + final assetImage = widget.image as AssetImage; + expect(assetImage.assetName, 'assets/image.png'); + }); + }); + + group('SvgGenImage', () { + test('properties and keyName', () { + const svg = SvgGenImage('assets/icon.svg'); + expect(svg.path, 'assets/icon.svg'); + expect(svg.keyName, 'assets/icon.svg'); + + const packageSvg = SvgGenImage('assets/icon.svg', package: 'pkg'); + expect(packageSvg.path, 'assets/icon.svg'); + expect(packageSvg.keyName, r'packages/pkg/assets/icon.svg'); + }); + + testWidgets('svg returns SvgPicture widget', (tester) async { + const svg = SvgGenImage('assets/icon.svg'); + final widget = svg.svg(); + expect(widget.bytesLoader, isA()); + final loader = widget.bytesLoader as SvgAssetLoader; + expect(loader.assetName, 'assets/icon.svg'); + expect(loader.packageName, isNull); + }); + + testWidgets('vec returns SvgPicture widget with AssetBytesLoader', (tester) async { + const vec = SvgGenImage.vec('assets/icon.vec'); + final widget = vec.svg(); + expect(widget.bytesLoader, isA()); + final loader = widget.bytesLoader as AssetBytesLoader; + expect(loader.assetName, 'assets/icon.vec'); + expect(loader.packageName, isNull); + }); + }); +}