47 lines
1.2 KiB
Dart
47 lines
1.2 KiB
Dart
import 'dart:ui';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class GlassmorphismContainer extends StatelessWidget {
|
|
final Widget child;
|
|
final double borderRadius;
|
|
final double sigmaX;
|
|
final double sigmaY;
|
|
final EdgeInsetsGeometry? padding;
|
|
|
|
const GlassmorphismContainer({
|
|
super.key,
|
|
required this.child,
|
|
this.borderRadius = 12,
|
|
this.sigmaX = 10,
|
|
this.sigmaY = 10,
|
|
this.padding,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isLight = Theme.of(context).brightness == Brightness.light;
|
|
final bgColor = isLight
|
|
? Colors.white.withValues(alpha: 0.7)
|
|
: Colors.black.withValues(alpha: 0.3);
|
|
final borderColor = isLight
|
|
? Colors.white.withValues(alpha: 0.3)
|
|
: Colors.white.withValues(alpha: 0.1);
|
|
|
|
return ClipRRect(
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
|
child: BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: sigmaX, sigmaY: sigmaY),
|
|
child: Container(
|
|
padding: padding,
|
|
decoration: BoxDecoration(
|
|
color: bgColor,
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
|
border: Border.all(color: borderColor),
|
|
),
|
|
child: child,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|