toMaterialTheme method
Converts this TsdtechThemeData into a Flutter ThemeData that can be applied to a MaterialApp. Useful when the host app wants to align its own theme with the TSDTech brand.
Implementation
ThemeData toMaterialTheme() {
final colorScheme = ColorScheme(
brightness: brightness,
primary: primaryColor,
onPrimary: textOnPrimaryColor,
secondary: accentColor,
onSecondary: textOnPrimaryColor,
error: errorColor,
onError: TsdtechColors.white,
surface: surfaceColor,
onSurface: textPrimaryColor,
);
return ThemeData(
colorScheme: colorScheme,
fontFamily: fontFamily,
textTheme: _buildTextTheme(),
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(borderRadius),
borderSide: BorderSide(color: outlineColor),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(borderRadius),
borderSide: BorderSide(color: outlineColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(borderRadius),
borderSide: BorderSide(color: primaryColor, width: 2),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(borderRadius),
borderSide: BorderSide(color: errorColor),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
filled: true,
fillColor: surfaceVariantColor,
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: primaryColor,
foregroundColor: textOnPrimaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadius),
),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 14),
textStyle: TsdtechTextStyles.labelLarge,
),
),
cardTheme: CardThemeData(
color: surfaceColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadius),
side: BorderSide(color: outlineColor),
),
elevation: 0,
),
);
}