38 lines
912 B
Dart
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,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|