How to create a transparent full screen dialog on top of activity - Flutter

后端 未结 3 795
挽巷
挽巷 2021-02-05 06:32

I am trying to create a transparent full screen dialog on top of activity. I have tried following this thread but solution doesn\'t work.

In short , what I need

相关标签:
3条回答
  • 2021-02-05 07:20

    For me the following worked:

    showDialog(
      context: context,
      builder: (_) => Material(
        type: MaterialType.transparency,
        child: Center(
          // Aligns the container to center
          child: Container(
            // A simplified version of dialog.
            width: 100.0,
            height: 56.0,
            color: Colors.green,
            child: Text('jojo'),
          ),
        ),
      ),
    );
    
    0 讨论(0)
  • 2021-02-05 07:22

    Screenshot (showGeneralDialog):


    Code:

    Widget build(BuildContext context) {
      return Scaffold(
        body: SizedBox.expand(child: FlutterLogo()),
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.open_in_new),
          onPressed: () {
            showGeneralDialog(
              context: context,
              barrierColor: Colors.black54,
              pageBuilder: (_, __, ___) => Container(child: Material(child: Text('Dialog'))),
            );
          },
        ),
      );
    }
    
    0 讨论(0)
  • 2021-02-05 07:24
    Navigator.of(context).push(PageRouteBuilder(
        opaque: false,
        pageBuilder: (BuildContext context, _, __) {
            return YourFullScreenAlertDialog()
        }
    ));
    

    YourFullScreenAlertDialog could be a widget that has a background color, Colors.transparent, like @creativecreatorormaybenot mentioned earlier.

    0 讨论(0)
提交回复
热议问题