效果图:
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'),
),
],
),
));
});