createLiquidGlassTheme function
ThemeData
createLiquidGlassTheme({
- LiquidGlassConfig config = const LiquidGlassConfig(),
- ColorScheme? colorScheme,
Implementation
ThemeData createLiquidGlassTheme({
LiquidGlassConfig config = const LiquidGlassConfig(),
ColorScheme? colorScheme,
}) {
final defaultColorScheme = const ColorScheme.light(
primary: Color(0xFF007AFF), // iOS system blue
secondary: Color(0xFF34C759), // iOS system green
surface: Color(0xFFF2F2F7), // iOS system background
onSurface: Color(0xFFF2F2F7),
);
final effectiveColorScheme = colorScheme ?? defaultColorScheme;
final elevatedButtonStyle = ElevatedButton.styleFrom(
foregroundColor: effectiveColorScheme.onPrimary,
backgroundColor: effectiveColorScheme.primary,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
elevation: 0,
shadowColor: Colors.transparent,
).copyWith(
overlayColor: WidgetStateProperty.resolveWith<Color>((states) {
if (states.contains(WidgetState.pressed)) {
return effectiveColorScheme.primary.withValues(alpha:0.2);
}
return Colors.transparent;
}),
);
final outlinedButtonStyle = OutlinedButton.styleFrom(
foregroundColor: effectiveColorScheme.primary,
backgroundColor: Colors.transparent,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
side: BorderSide(color: effectiveColorScheme.primary, width: 1.5),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
).copyWith(
overlayColor: WidgetStateProperty.resolveWith<Color>((states) {
if (states.contains(WidgetState.pressed)) {
return effectiveColorScheme.primary.withValues(alpha:0.1);
}
return Colors.transparent;
}),
);
return ThemeData(
useMaterial3: true,
colorScheme: colorScheme ?? defaultColorScheme,
appBarTheme: const AppBarTheme(
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
surfaceTintColor: Colors.transparent,
shadowColor: Colors.transparent,
),
cardTheme: CardThemeData(
elevation: 0,
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
surfaceTintColor: Colors.transparent,
),
dialogTheme: const DialogThemeData(
backgroundColor: Color(0xFFF2F2F7),
surfaceTintColor: Colors.transparent,
elevation: 0,
),
extensions: <ThemeExtension<dynamic>>[
LiquidGlassTheme.fromConfig(config).copyWith(
elevatedButtonStyle: elevatedButtonStyle,
outlinedButtonStyle: outlinedButtonStyle,
),
],
);
}