noticeX<T> method
Future<T?>
noticeX<T>(
- BuildContext context, {
- required Widget title,
- required Widget content,
- Widget? button,
- VoidCallback? onPressed,
- double indent = 28,
- bool? dark,
Do not use it. TODO 扩展出内容,仅有布局框架。
Implementation
Future<T?> noticeX<T>(
BuildContext context, {
required Widget title,
required Widget content,
// Widget button = const ElevatedButton(
// child: Text("Got it"),
// onPressed: null,
// ),
Widget? button,
VoidCallback? onPressed,
double indent = 28,
bool? dark,
}) {
// 取宽,屏幕的60%用于对话框。
double _width = MediaQuery.of(context).size.width * 0.72;
bool _dark = dark ?? (Theme.of(context).brightness == Brightness.dark);
return showDialog(
context: context,
builder: (context) {
return Dialog(
backgroundColor: _dark ? Colors.black45 : Colors.white24,
// 对话框区域背景色
elevation: 12.0,
insetPadding: EdgeInsets.zero,
clipBehavior: Clip.hardEdge,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: _width,
padding: EdgeInsets.fromLTRB(indent, 28.0, 8.0, 8.0),
child: title,
),
SizedBox(
width: _width,
child: Divider(
height: 18,
thickness: 0.8,
indent: indent,
color: _dark ? Colors.white : Colors.black87,
),
),
Container(
width: _width,
padding: EdgeInsets.fromLTRB((indent + 8.0), 8.0, 8.0, 8.0),
child: content,
),
Container(
width: _width,
alignment: Alignment.centerRight,
padding: EdgeInsets.only(right: 8.0),
child: button,
)
],
),
);
},
);
}