如何在颤动中显示带有动画的自定义对话框?
how to show a Custom Dialog Box with animation in flutter?
我想在 flutter 中按下按钮时显示这样的自定义对话框,是否有任何包或小部件可以将其存档?
据我所知,没有您需要的软件包。
您必须 make
这 custom widget
确保 root of the widget is StatefulBuilder
以便您可以让轮播按预期工作。
然后只需调用
showDialog(
context: context,
builder: (BuildContext context) => WidgetYouMade()
);
对于像这样的小部件(自定义对话框),这是最好的方法,这将为您提供良好的缩放过渡,并且您可以将任何小部件设置为自定义对话框。
showGeneralDialog(
barrierColor: Colors.black.withOpacity(0.5),
transitionBuilder: (context, a1, a2, widget) {
return Transform.scale(
scale: a1.value,
//here inside opacity define your child instead projectdetails()
child: Opacity(opacity: a1.value, child: ProjectDetails()),
);
},
transitionDuration: Duration(milliseconds: 200),
barrierDismissible: true,
barrierLabel: '',
context: context,
pageBuilder: (context, animation1, animation2) {
//return a emty container
return Container();
});
我想在 flutter 中按下按钮时显示这样的自定义对话框,是否有任何包或小部件可以将其存档?
据我所知,没有您需要的软件包。
您必须 make
这 custom widget
确保 root of the widget is StatefulBuilder
以便您可以让轮播按预期工作。
然后只需调用
showDialog(
context: context,
builder: (BuildContext context) => WidgetYouMade()
);
对于像这样的小部件(自定义对话框),这是最好的方法,这将为您提供良好的缩放过渡,并且您可以将任何小部件设置为自定义对话框。
showGeneralDialog(
barrierColor: Colors.black.withOpacity(0.5),
transitionBuilder: (context, a1, a2, widget) {
return Transform.scale(
scale: a1.value,
//here inside opacity define your child instead projectdetails()
child: Opacity(opacity: a1.value, child: ProjectDetails()),
);
},
transitionDuration: Duration(milliseconds: 200),
barrierDismissible: true,
barrierLabel: '',
context: context,
pageBuilder: (context, animation1, animation2) {
//return a emty container
return Container();
});