【问题标题】:how to show a Custom Dialog Box with animation in flutter?如何在颤动中显示带有动画的自定义对话框?
【发布时间】:2021-11-06 08:42:23
【问题描述】:

我想在颤动中按下按钮时显示这样的自定义对话框,是否有任何包或小部件可以存档?

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies flutter-web flutter-test


    【解决方案1】:

    据我所知,没有您需要的软件包。

    您必须make custom widget 确保root of the widget is StatefulBuilder 才能让您的轮播按需要工作。

    然后简单地调用

    showDialog(
        context: context,
        builder: (BuildContext context) => WidgetYouMade()
    );
    

    【讨论】:

      【解决方案2】:

      这是此类小部件(自定义对话框)的最佳方法,这将为您提供良好的比例转换,您可以将任何小部件设置为自定义对话框。

      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();
      
          });
      

      【讨论】:

        猜你喜欢
        • 2019-09-06
        • 1970-01-01
        • 2016-10-15
        • 2011-06-16
        • 2019-02-23
        • 2020-08-22
        • 1970-01-01
        相关资源
        最近更新 更多