diff --git a/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_image.dart b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_image.dart index cd96c3bf60..3584574450 100644 --- a/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_image.dart +++ b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_image.dart @@ -1,12 +1,12 @@ import 'package:flutter/widgets.dart'; -/// [CatalystImage] is a wrapper around [Image.asset] that sets the package -/// property to `catalyst_voices_assets` by default. -/// This allows the package to be used without having to specify -/// the package name every time. +/// [CatalystImage] extends [Image] to have an asset constructor +/// tat sets the package property to `catalyst_voices_assets` by default. +/// This allows to use the asset without having to specify the package name +/// every time. /// For more information, see [Image.asset]. -final class CatalystImage { - static Image asset( +final class CatalystImage extends Image { + CatalystImage.asset( String name, { AssetBundle? bundle, ImageFrameBuilder? frameBuilder, @@ -30,31 +30,29 @@ final class CatalystImage { FilterQuality filterQuality = FilterQuality.low, int? cacheWidth, int? cacheHeight, - }) { - return Image.asset( - name, - 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, - filterQuality: filterQuality, - cacheWidth: cacheWidth, - cacheHeight: cacheHeight, - package: package, - ); - } + }) : super.asset( + name, + 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, + filterQuality: filterQuality, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + package: package, + ); } diff --git a/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_svg_picture.dart b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_svg_picture.dart index e13aedadd1..ff37a53415 100644 --- a/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_svg_picture.dart +++ b/catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_svg_picture.dart @@ -1,13 +1,13 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_svg/flutter_svg.dart'; -/// [CatalystSvgPicture] is a wrapper around [SvgPicture.asset] that sets the -/// package property to `catalyst_voices_assets` by default. +/// [CatalystSvgPicture] extends [SvgPicture] to have an asset constructor +/// tat sets the package property to `catalyst_voices_assets` by default. /// This allows to use the asset without having to specify the package name /// every time. /// For more information, see [SvgPicture.asset]. -final class CatalystSvgPicture { - static SvgPicture asset( +final class CatalystSvgPicture extends SvgPicture { + CatalystSvgPicture.asset( String name, { AssetBundle? bundle, String? semanticsLabel, @@ -23,23 +23,21 @@ final class CatalystSvgPicture { Clip clipBehavior = Clip.hardEdge, SvgTheme? theme, ColorFilter? colorFilter, - }) { - return SvgPicture.asset( - name, - bundle: bundle, - semanticsLabel: semanticsLabel, - excludeFromSemantics: excludeFromSemantics, - width: width, - height: height, - fit: fit, - alignment: alignment, - matchTextDirection: matchTextDirection, - package: package, - allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, - placeholderBuilder: placeholderBuilder, - clipBehavior: clipBehavior, - theme: theme, - colorFilter: colorFilter, - ); - } + }) : super.asset( + name, + bundle: bundle, + semanticsLabel: semanticsLabel, + excludeFromSemantics: excludeFromSemantics, + width: width, + height: height, + fit: fit, + alignment: alignment, + matchTextDirection: matchTextDirection, + package: package, + allowDrawingOutsideViewBox: allowDrawingOutsideViewBox, + placeholderBuilder: placeholderBuilder, + clipBehavior: clipBehavior, + theme: theme, + colorFilter: colorFilter, + ); }