Flutter AlertDialog巢狀單選框使用
阿新 • • 發佈:2020-12-13
技術標籤:Flutter
效果圖:
showGeneralDialog(
context: context,
pageBuilder: (context, anim1, anim2) {
return;
},
barrierColor: Colors.grey.withOpacity(.4),
barrierDismissible: true,
barrierLabel: "Tips",
transitionDuration: Duration(milliseconds: 400),
transitionBuilder: (context, anim1, anim2, child) {
return Transform.scale(
scale: anim1.value,
child: Opacity(
opacity: anim1.value,
child: AlertDialog(
shape: RoundedRectangleBorder (
borderRadius:
BorderRadius.all(Radius.circular(20))),
title: Text("Tips"),
content:StatefulBuilder(builder: (context, StateSetter setState){
return SingleChildScrollView(
child: Column(
children: [
RadioListTile(
value: 0,
groupValue: groupValue,
///點選狀態改變時的回撥 必選引數
onChanged: (v) {
setState(() {
groupValue = v;
});
},
title: Text("Pay \$1 only for"),
),
RadioListTile(
value: 1,
groupValue: groupValue,
onChanged: (v) {
setState(() {
groupValue = v;
});
},
title: Text("Pay \$3 for"),
),
],
),
);
}),
actions: [
FlatButton(
onPressed: () {
FocusScope.of(context).requestFocus(FocusNode());
Navigator.pop(context);
},
child: Text('Cancel'),
),
FlatButton(
onPressed: () {
FocusScope.of(context).requestFocus(FocusNode());
Navigator.pop(context);
},
child: Text('Pay Now'),
),
],
),
));
});