Files
tuiche/lib/component/tool/FrostedDialog.dart
2025-04-16 14:27:10 +08:00

38 lines
912 B
Dart

import 'dart:ui';
import 'package:flutter/material.dart';
class FrostedDialog extends StatelessWidget {
final Widget child;
final double blurSigma;
final Color barrierColor;
const FrostedDialog({
super.key,
required this.child,
this.blurSigma = 5.0,
this.barrierColor = const Color.fromRGBO(0, 0, 0, 0.5),
});
@override
Widget build(BuildContext context) {
return Stack(
children: [
// 毛玻璃背景
BackdropFilter(
filter: ImageFilter.blur(sigmaX: blurSigma, sigmaY: blurSigma),
child: Container(
color: Colors.transparent,
),
),
Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
backgroundColor: Colors.transparent, // 背景透明,由 child 自己决定
child: child,
),
],
);
}
}