toMaterialTheme method

ThemeData toMaterialTheme({
  1. Brightness brightness = Brightness.light,
})

Implementation

ThemeData toMaterialTheme({Brightness brightness = Brightness.light}) {
  return ThemeData(
    useMaterial3: true,
    brightness: brightness,
    colorScheme: ColorScheme.fromSeed(
      seedColor: colors.primary,
      brightness: brightness,
    ).copyWith(
      primary: colors.primary,
      onPrimary: colors.textInverse,
      secondary: colors.secondary,
      onSecondary: colors.textInverse,
      error: colors.error,
      onError: colors.textInverse,
      surface: colors.surface,
      onSurface: colors.textPrimary,
    ),
    scaffoldBackgroundColor: colors.background,
    appBarTheme: AppBarTheme(
      backgroundColor: colors.surface,
      foregroundColor: colors.textPrimary,
      elevation: 0,
      centerTitle: true,
      titleTextStyle: typography.headlineSmall.copyWith(
        color: colors.textPrimary,
        fontWeight: FontWeight.w600,
      ),
    ),
    elevatedButtonTheme: ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        backgroundColor: colors.primary,
        foregroundColor: colors.textInverse,
        padding: EdgeInsets.symmetric(
          horizontal: spacing.buttonPaddingX,
          vertical: spacing.buttonPaddingY,
        ),
        shape: RoundedRectangleBorder(
          borderRadius: borders.button,
        ),
      ),
    ),
    cardTheme: CardThemeData(
      color: colors.surface,
      elevation: 0,
      shape: RoundedRectangleBorder(
        borderRadius: borders.card,
      ),
    ),
    inputDecorationTheme: InputDecorationTheme(
      filled: true,
      fillColor: colors.gray100,
      border: OutlineInputBorder(
        borderRadius: borders.input,
        borderSide: BorderSide.none,
      ),
      enabledBorder: OutlineInputBorder(
        borderRadius: borders.input,
        borderSide: BorderSide.none,
      ),
      focusedBorder: OutlineInputBorder(
        borderRadius: borders.input,
        borderSide: BorderSide(color: colors.primary, width: 2),
      ),
      errorBorder: OutlineInputBorder(
        borderRadius: borders.input,
        borderSide: BorderSide(color: colors.error, width: 2),
      ),
      contentPadding: EdgeInsets.symmetric(
        horizontal: spacing.inputPaddingX,
        vertical: spacing.inputPaddingY,
      ),
    ),
    textTheme: TextTheme(
      displayLarge: typography.displayLarge.copyWith(color: colors.textPrimary),
      displayMedium: typography.displayMedium.copyWith(color: colors.textPrimary),
      displaySmall: typography.displaySmall.copyWith(color: colors.textPrimary),
      headlineLarge: typography.headlineLarge.copyWith(color: colors.textPrimary),
      headlineMedium: typography.headlineMedium.copyWith(color: colors.textPrimary),
      headlineSmall: typography.headlineSmall.copyWith(color: colors.textPrimary),
      titleLarge: typography.titleLarge.copyWith(color: colors.textPrimary),
      titleMedium: typography.titleMedium.copyWith(color: colors.textPrimary),
      titleSmall: typography.titleSmall.copyWith(color: colors.textPrimary),
      bodyLarge: typography.bodyLarge.copyWith(color: colors.textPrimary),
      bodyMedium: typography.bodyMedium.copyWith(color: colors.textPrimary),
      bodySmall: typography.bodySmall.copyWith(color: colors.textSecondary),
      labelLarge: typography.labelLarge.copyWith(color: colors.textPrimary),
      labelMedium: typography.labelMedium.copyWith(color: colors.textPrimary),
      labelSmall: typography.labelSmall.copyWith(color: colors.textSecondary),
    ),
  );
}