美文网首页
flutter自定义对话框

flutter自定义对话框

作者: 太sun阳 | 来源:发表于2019-03-28 17:42 被阅读0次

先上样式:

效果图

代码:

class CommonDialogextends Dialog {

final title;

  final content;

  final rightButtonText;

  final leftButtonText;

  final VoidCallbackonPressLeftButton;

  final VoidCallbackonPressRightButton;

  final boolbarrierDismissible;//true点击外部区域关闭对话框

  CommonDialog(

{this.title ="提示",

      this.content ="",

      this.rightButtonText ="",

      this.leftButtonText ="",

      this.onPressLeftButton,

      this.onPressRightButton,

      this.barrierDismissible=true});

  @override

  Widgetbuild(BuildContext context) {

return Material(

type: MaterialType.transparency,

        child:Stack(

fit: StackFit.expand,

          children: [

GestureDetector(

onTap: (){///点击的对话框外部区域

              if(barrierDismissible){

NavigatorUtil.last(context);

              }

},

        ),

            new Center(

child:Container(

width: Constant.WIDTH_SCALE * Util.getScreenWidth(context),

                decoration:ShapeDecoration(

color: Colors.white,

                    shape:RoundedRectangleBorder(

borderRadius:BorderRadius.circular(6))),

                child:Column(

mainAxisSize: MainAxisSize.min,

                  children: [

new Offstage(

offstage:title =="", //offstage(舞台外) true不显示

                      child:Container(

alignment: Alignment.center,

                        height:60,

                        padding:const EdgeInsets.only(top:24, bottom:12),

                        child:new Text(

title,

                          style: JTextStyle.largeTextStyleBlack,

                        ),

                      ),

                    ),

//                new Divider(

//                  height: 1,

//                ),

                    Container(

margin:const EdgeInsets.fromLTRB(20, 0, 20, 16),

                      child:new Text(

content,

                        style: JTextStyle.smallTextStyleGray6,

                      ),

                    ),

                    new Divider(

height:1,

                    ),

                    Container(

height:60,

                      child:new Row(

mainAxisAlignment:

(leftButtonText !="" &&rightButtonText !="")

? MainAxisAlignment.spaceAround

                            : MainAxisAlignment.center,

                        children: [

new Offstage(

offstage:leftButtonText =="",

                            child:new GestureDetector(

onTap:onPressLeftButton,

                                child:new Container(

height:60,

                                  alignment: Alignment.center,

                                  padding:

const EdgeInsets.only(left:30, right:30),

                                  color: Colors.white,

                                  child:new Text(

leftButtonText,

                                    style: JTextStyle.largeTextStyleBlack,

                                  ),

                                )),

                          ),

                          new Offstage(

offstage:rightButtonText =="",

                            child:new GestureDetector(

onTap:onPressRightButton,

                                child:new Container(

height:60,

                                  alignment: Alignment.center,

                                  padding:

const EdgeInsets.only(left:30, right:30),

                                  color: Colors.white,

                                  child:new Text(

rightButtonText,

                                    style: JTextStyle.largeTextStyleBlue,

                                  ),

                                )),

                          ),

                        ],

                      ),

                    ),

                  ],

                ),

              ),

            ),

          ],

        )

);

  }

}

相关文章

  • Flutter 弹框6种

    1、Flutter 项目默认升级弹框和自定义升级弹框 注:在pubspec.yaml中添加 插件 #版本更新对话框...

  • Flutter怎么自定义一个对话框

    Flutter怎么自定义一个对话框?怎么调用?正好我刚写完一个隐私协议对话框,要求同意协议前,不初始化第三方SDK...

  • flutter自定义对话框

    先上样式: 代码: class CommonDialogextends Dialog { final title;...

  • Flutter 学习 - Widget 之 对话框

    前言 本篇我们介绍Flutter中常用的对话框,先看下效果图 正文 Flutter 中对话框也是Widget,有两...

  • QT 增加最小化按钮

    默认对话框 自定义

  • 第二十四章 对话框

    一、系统对话框&自定义对话框 1.系统对话框 AlertDialog 普通对话框 多按钮普通对话框 列表对话框 单...

  • Flutter自定义加载对话框

    在做flutter开发的时候,找了一些类似于ios中 MBProgressHUD,SVProgressHUD第三方...

  • popupWindow自定义(1)

    popupWindow自定义(2) 1、自定义布局(密码框、对话框等等)2、从下往上弹出效果的实现 一、对话框 第...

  • Flutter 踩坑记录

    1.问题描述: 一个聊天对话页面,由于对话框形状需要自定义,因此采用了CustomPainter来自定义绘制对话框...

  • flutter(七.自定义view)

    Tags: flutter 自定义View [TOC] 1. 概述 与Flutter自带Widget一样,自定义v...

网友评论

      本文标题:flutter自定义对话框

      本文链接:https://www.haomeiwen.com/subject/soscbqtx.html