0
点赞
收藏
分享

微信扫一扫

代码随想录阅读笔记-二叉树【将有序数组转换为二叉搜索树】

color_小浣熊 04-09 06:30 阅读 0
flutter

AlertDialog的定义

  const AlertDialog({
    super.key,
    this.icon,
    this.iconPadding,
    this.iconColor,
    this.title,
    this.titlePadding,
    this.titleTextStyle,
    this.content,
    this.contentPadding,
    this.contentTextStyle,
    this.actions,
    this.actionsPadding,
    this.actionsAlignment,
    this.actionsOverflowAlignment,
    this.actionsOverflowDirection,
    this.actionsOverflowButtonSpacing,
    this.buttonPadding,
    this.backgroundColor,
    this.elevation,
    this.shadowColor,
    this.surfaceTintColor,	
    this.semanticLabel,
    this.insetPadding = _defaultInsetPadding,
    this.clipBehavior = Clip.none,
    this.shape,
    this.alignment,
    this.scrollable = false,
  });

属性:

属性名属性值
icon显示在对话框顶部的可选图标
iconPaddingicon图标内边距
iconColoricon图标的颜色
titlePadding标题内边距
titleTextStyle标题样式
contentDialog内容
contentPadding内容内边距
contentTextStyle内容样式
actions控件底部显示的操作集按钮
actionsPadding操作集内边距
actionsAlignment操作集对齐方式
actionsOverflowAlignment操作集溢出对齐方式
actionsOverflowDirection操作机溢出装饰
actionsOverflowButtonSpacing操作集按钮间距
buttonPadding按钮内边距
backgroundColorDiolog背景色
elevation设置阴影的大小,若没设置shadowColor则无效
shadowColor设置阴影颜色
surfaceTintColor作对话框背景色上的表面色调叠加的颜色, 它反映了对话框的 elevation高程
clipBehavior超出部分剪切方式
insetPadding对话框距离屏幕边缘间距
shape对话框外形
alignment子控件对齐方式
scrollable是否可以滚动

实例:

class AlertDialogWidget extends StatelessWidget {
  const AlertDialogWidget({super.key});

  
  Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: null,
      style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.indigo)),
      child: SizedBox(
        child: TextButton(
          onPressed: () {
            showDialog(context: context, builder: (context) {
              return AlertDialog(
                icon: const Icon(Icons.person), // 图标
                iconPadding: const EdgeInsets.only(top: 50), // 图标的内边距
                iconColor: Colors.indigo, // 图标颜色
                title: const Text("title"), // Dialog标题
                titleTextStyle: const TextStyle(color: Colors.indigo), // 标题样式
                content: const Text("I'm AlertDialog content."), // Dialog内容
                actions: [ // Dialog事件
                  TextButton(
                    onPressed: () => Navigator.pop(context, 'Cancel'),
                    child: const Text("cancel"),
                  ),
                  TextButton(
                    onPressed: () => Navigator.pop(context, 'Confirm'),
                    child: const Text("confirm"),
                  ),
                ],
                actionsAlignment: MainAxisAlignment.center,
                backgroundColor: const Color(0xFFFF0000),
                elevation: 24, // 控制阴影的大,若没设置shadowColor则无效
                shadowColor: const Color(0xFFFF0000), // 设置阴影颜色
                surfaceTintColor: const Color(0xFF0000FF), // surfaceTintColor
              );
            }
          );
        },
        child: const Text(
          "alert",
          style: TextStyle(
            fontSize: 12,
            color: Colors.white,
          ),
        ),
      ),
    ));
  }
}

注意

在这里插入图片描述

举报

相关推荐

0 条评论