-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add svg support for flutter_gen and add
CatalystSvgPicture
wr…
…apper.
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
catalyst_voices/packages/catalyst_voices_assets/lib/src/catalyst_svg_picture.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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. | ||
/// 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( | ||
String name, { | ||
AssetBundle? bundle, | ||
String? semanticsLabel, | ||
bool excludeFromSemantics = false, | ||
double? width, | ||
double? height, | ||
BoxFit fit = BoxFit.contain, | ||
Alignment alignment = Alignment.center, | ||
bool matchTextDirection = false, | ||
String package = 'catalyst_voices_assets', | ||
bool allowDrawingOutsideViewBox = false, | ||
Widget Function(BuildContext)? placeholderBuilder, | ||
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, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters