themed method
- BuildContext context, {
- 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,
Creates a themed SVG image based on the current context
.
Please refer to the table below for the color substitutions:
Hex Code | Replaced with | Description |
---|---|---|
#FF5733 |
ColorScheme.primary |
Main color of the app's theme. |
#FFC300 |
ColorScheme.secondary |
Accents and highlights that complement the primary. |
#FF5733 |
ColorScheme.secondaryVariant |
Lighter or alternate shade of the secondary color. |
#DAF7A6 |
ColorScheme.surface |
Surfaces like cards and sheets. |
#900C3F |
ColorScheme.error |
Error messages and error state indications. |
#581845 |
ColorScheme.onPrimary |
Text and icons on top of the primary color. |
#1F618D |
ColorScheme.onSecondary |
Text and icons on top of the secondary color. |
#17202A |
ColorScheme.onSurface |
Text and icons on top of surfaces. |
#F1C40F |
ColorScheme.onError |
Text and icons on top of error color surfaces. |
#000000 |
TextTheme.bodyNormal.color |
Normal text color. |
Implementation
SvgPicture themed(
BuildContext context, {
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,
}) {
final loader = SvgAssetLoader(
path,
assetBundle: bundle,
packageName: package,
theme: theme,
colorMapper: ContextColorMapper(context),
);
return SvgPicture(
loader,
key: key,
matchTextDirection: matchTextDirection,
width: width,
height: height,
fit: fit,
alignment: alignment,
allowDrawingOutsideViewBox: allowDrawingOutsideViewBox,
placeholderBuilder: placeholderBuilder,
semanticsLabel: semanticsLabel,
excludeFromSemantics: excludeFromSemantics,
colorFilter: colorFilter,
clipBehavior: clipBehavior,
);
}