toMfaTheme method

MfaThemeData toMfaTheme()

An MfaThemeData using this theme's colour scheme and text theme.

Material has no success or warning roles, so those keep the accessible defaults for the brightness.

Implementation

MfaThemeData toMfaTheme() {
  final scheme = colorScheme;
  final base = MfaThemeData.fallback(scheme.brightness);
  TextStyle style(TextStyle? from, TextStyle fallback, Color color) =>
      (from ?? fallback).copyWith(color: color);
  return base.copyWith(
    primary: scheme.primary,
    onPrimary: scheme.onPrimary,
    surface: scheme.surface,
    onSurface: scheme.onSurface,
    onSurfaceVariant: scheme.onSurfaceVariant,
    outline: scheme.outline,
    error: scheme.error,
    codeTextStyle: (textTheme.headlineMedium ?? const TextStyle())
        .merge(MfaThemeData.defaultCodeTextStyle)
        .copyWith(color: scheme.onSurface),
    titleTextStyle: style(
      textTheme.titleMedium,
      base.titleTextStyle,
      scheme.onSurface,
    ),
    bodyTextStyle: style(
      textTheme.bodyMedium,
      base.bodyTextStyle,
      scheme.onSurface,
    ),
    labelTextStyle: style(
      textTheme.bodySmall,
      base.labelTextStyle,
      scheme.onSurfaceVariant,
    ),
  );
}