noticeX<T> static method
自定义内容标题等,当时显示风格不变。 Do not use it. TODO 扩展出内容,仅有布局框架。
Implementation
static Future<T?> noticeX<T>(
BuildContext context, {
required Widget title,
required Widget content,
Widget? button,
double indent = 28,
bool? dark,
}) {
// 取宽,屏幕的60%用于对话框。
double _width = MediaQuery.of(context).size.width * 0.72;
bool _dark = dark ?? (Theme.of(context).brightness == Brightness.dark);
Color _barrierColor = _dark ? Color(0xaa000000) : Color(0x9effffff);
Color _backgroundColor = _dark ? Colors.black45 : Colors.white60;
// Color _fontColor = _dark ? Colors.white : Colors.black;
return showDialog(
context: context,
barrierColor: _barrierColor,
builder: (context) {
return Dialog(
backgroundColor: _backgroundColor,
// 对话框区域背景色
elevation: 12.0,
insetPadding: EdgeInsets.zero,
clipBehavior: Clip.hardEdge,
shape: const RoundedRectangleBorder(
borderRadius: _borderRadius,
),
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,
)
],
),
);
},
);
}