themed method

SvgPicture themed(
  1. BuildContext context, {
  2. Key? key,
  3. bool matchTextDirection = false,
  4. AssetBundle? bundle,
  5. String? package,
  6. double? width,
  7. double? height,
  8. BoxFit fit = BoxFit.contain,
  9. AlignmentGeometry alignment = Alignment.center,
  10. bool allowDrawingOutsideViewBox = false,
  11. WidgetBuilder? placeholderBuilder,
  12. String? semanticsLabel,
  13. bool excludeFromSemantics = false,
  14. SvgTheme? theme,
  15. ColorFilter? colorFilter,
  16. 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,
  );
}