applySafaehMaterialChrome function

ThemeData applySafaehMaterialChrome(
  1. ThemeData theme, {
  2. required ColorScheme colorScheme,
  3. required TextTheme textTheme,
  4. required Color dividerColor,
  5. required Color outlineColor,
  6. required Color errorColor,
  7. required Color primarySeed,
  8. Color? iconColor,
  9. bool alwaysShowScrollbars = false,
  10. PageTransitionsTheme? pageTransitionsTheme,
  11. SafaehMaterialRadii radii = const SafaehMaterialRadii(),
})

Material chrome shared by host theme factories.

Hosts still own fonts, seed colors, and their own ThemeExtensions. Call this, then copyWith(extensions:) for host tokens.

Implementation

ThemeData applySafaehMaterialChrome(
  ThemeData theme, {
  required ColorScheme colorScheme,
  required TextTheme textTheme,
  required Color dividerColor,
  required Color outlineColor,
  required Color errorColor,
  required Color primarySeed,
  Color? iconColor,
  bool alwaysShowScrollbars = false,
  PageTransitionsTheme? pageTransitionsTheme,
  SafaehMaterialRadii radii = const SafaehMaterialRadii(),
}) {
  return theme.copyWith(
    colorScheme: colorScheme,
    textTheme: textTheme,
    pageTransitionsTheme: pageTransitionsTheme ?? theme.pageTransitionsTheme,
    iconTheme: IconThemeData(color: iconColor ?? colorScheme.onSurface),
    scrollbarTheme: alwaysShowScrollbars
        ? ScrollbarThemeData(
            thumbVisibility: WidgetStateProperty.all(true),
            trackVisibility: WidgetStateProperty.all(true),
          )
        : theme.scrollbarTheme,
    appBarTheme: AppBarTheme(
      centerTitle: radii.appBarCenterTitle,
      elevation: radii.appBarElevation,
      backgroundColor: colorScheme.surface,
      foregroundColor: colorScheme.onSurface,
      iconTheme: IconThemeData(color: colorScheme.onSurface),
    ),
    cardTheme: CardThemeData(
      elevation: radii.cardElevation,
      shadowColor: colorScheme.brightness == Brightness.dark
          ? Colors.black.withValues(alpha: 0.45)
          : colorScheme.shadow,
      surfaceTintColor: Colors.transparent,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(radii.card),
        side: BorderSide(color: colorScheme.outlineVariant, width: 1),
      ),
      color: colorScheme.surfaceContainerHighest,
    ),
    dividerTheme: DividerThemeData(
      color: dividerColor,
      thickness: radii.dividerThickness,
      space: radii.dividerSpacing,
    ),
    inputDecorationTheme: InputDecorationTheme(
      border: OutlineInputBorder(
        borderRadius: BorderRadius.circular(radii.input),
        borderSide: BorderSide(
          color: outlineColor,
          width: radii.inputDefaultBorderWidth,
        ),
      ),
      enabledBorder: OutlineInputBorder(
        borderRadius: BorderRadius.circular(radii.input),
        borderSide: BorderSide(
          color: outlineColor,
          width: radii.inputDefaultBorderWidth,
        ),
      ),
      focusedBorder: OutlineInputBorder(
        borderRadius: BorderRadius.circular(radii.input),
        borderSide: BorderSide(
          color: primarySeed,
          width: radii.inputFocusedBorderWidth,
        ),
      ),
      errorBorder: OutlineInputBorder(
        borderRadius: BorderRadius.circular(radii.input),
        borderSide: BorderSide(
          color: errorColor,
          width: radii.inputDefaultBorderWidth,
        ),
      ),
    ),
    chipTheme: ChipThemeData(
      showCheckmark: false,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(radii.chip),
      ),
    ),
    snackBarTheme: SnackBarThemeData(
      backgroundColor: colorScheme.surfaceContainerHighest,
      contentTextStyle: TextStyle(color: colorScheme.onSurface),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(radii.snackBar),
      ),
      behavior: SnackBarBehavior.floating,
    ),
  );
}