54 lines
1.3 KiB
Dart
54 lines
1.3 KiB
Dart
|
|
import 'dart:ui';
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
class GlassCard extends StatelessWidget {
|
||
|
|
const GlassCard({
|
||
|
|
super.key,
|
||
|
|
required this.child,
|
||
|
|
this.padding = const EdgeInsets.all(16),
|
||
|
|
this.margin,
|
||
|
|
this.borderRadius = 16,
|
||
|
|
this.blur = 10,
|
||
|
|
this.backgroundColor,
|
||
|
|
this.borderColor,
|
||
|
|
});
|
||
|
|
|
||
|
|
final Widget child;
|
||
|
|
final EdgeInsetsGeometry padding;
|
||
|
|
final EdgeInsetsGeometry? margin;
|
||
|
|
final double borderRadius;
|
||
|
|
final double blur;
|
||
|
|
final Color? backgroundColor;
|
||
|
|
final Color? borderColor;
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
final effectiveBackground =
|
||
|
|
backgroundColor ?? const Color(0xFF1E293B).withOpacity(0.6);
|
||
|
|
final effectiveBorder =
|
||
|
|
borderColor ?? Colors.white.withOpacity(0.08);
|
||
|
|
|
||
|
|
Widget card = ClipRRect(
|
||
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
||
|
|
child: BackdropFilter(
|
||
|
|
filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
|
||
|
|
child: Container(
|
||
|
|
padding: padding,
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
color: effectiveBackground,
|
||
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
||
|
|
border: Border.all(color: effectiveBorder, width: 1),
|
||
|
|
),
|
||
|
|
child: child,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
|
||
|
|
if (margin != null) {
|
||
|
|
return Container(margin: margin, child: card);
|
||
|
|
}
|
||
|
|
|
||
|
|
return card;
|
||
|
|
}
|
||
|
|
}
|