先上樣式:

代碼:
class CommonDialogextends Dialog {
final title;
? final content;
? final rightButtonText;
? final leftButtonText;
? final VoidCallbackonPressLeftButton;
? final VoidCallbackonPressRightButton;
? final boolbarrierDismissible;//true點(diǎn)擊外部區(qū)域關(guān)閉對(duì)話框
? 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: (){///點(diǎn)擊的對(duì)話框外部區(qū)域
? ? ? ? ? ? ? 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(舞臺(tái)外) 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,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? )),
? ? ? ? ? ? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? ? ? ? ? ],
? ? ? ? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ? ? ],
? ? ? ? ? ? ? ? ),
? ? ? ? ? ? ? ),
? ? ? ? ? ? ),
? ? ? ? ? ],
? ? ? ? )
);
? }
}