gpt4 book ai didi

flutter - 我如何设置弹出式AlertDialog?

转载 作者:行者123 更新时间:2023-12-03 04:23:24 34 4
gpt4 key购买 nike

当int等于或大于100时,如何设置弹出式AlertDialog?

 showDialog(
context: _context,
builder: (BuildContext context) => AlertDialog(
title: Text("$_winner Won"),
)
);



void scoreTeamA() {
setState(() {
outputTeamA += _choiceA;
});
}
// I would like to show outputTeamA on the AlertDialog


谢谢
穆罕默德

最佳答案

这就是我显示AlertDialog的方式

showAlertDialog() {
return showDialog(
context: context,
builder: (context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
side: BorderSide(color: Colors.redAccent, width: 2.0),
),
elevation: 6,
titlePadding: EdgeInsets.all(8.0),
titleTextStyle: TextStyle(
fontSize: 18, color: Colors.red, fontWeight: FontWeight.bold),
title: Text(
'This is the alert title',
textAlign: TextAlign.center,
),
contentPadding: EdgeInsets.all(8.0),
contentTextStyle: TextStyle(fontSize: 14, color: Colors.black),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('Content...')
//content goes here
],
),
actions: <Widget>[
FlatButton(
onPressed: () => Navigator.of(context).pop(), child: Text('Okay'))
],
),
);
}

然后您会检查是否检查
if( outputTeamA >= 100){
showAlertDialog();
}

当然,您可以在 AlertDialog中使用outputTeamA

关于flutter - 我如何设置弹出式AlertDialog?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61264215/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com