ContextColorMapper constructor
- BuildContext context
Creates a new ContextColorMapper with the given context
.
A ColorMapper that uses the current context to resolve colors based on the active theme. Used in SvgUtils.themed to resolve colors in SVG images.
Implementation
factory ContextColorMapper(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
final textTheme = theme.textTheme;
return ContextColorMapper._({
const Color(0xFFFF5733): colorScheme.primary,
const Color(0xFFFFC300): colorScheme.secondary,
const Color(0xFFDAF7A6): colorScheme.surface,
const Color(0xFF900C3F): colorScheme.error,
const Color(0xFF581845): colorScheme.onPrimary,
const Color(0xFF1F618D): colorScheme.onSecondary,
const Color(0xFF17202A): colorScheme.onSurface,
const Color(0xFFF1C40F): colorScheme.onError,
const Color(0xFF000000): textTheme.bodyMedium?.color,
const Color(0xFF0037ff): theme.scaffoldBackgroundColor,
const Color(0xFF00ff40): theme.dividerColor,
});
}