Show dialog on widget

前端 未结 4 1293
谎友^
谎友^ 2020-12-16 02:47

In flutter, we want to overlay a dialog above the widget.

We were able to display the dialog after pushing the button.

However, we want to display that dialo

4条回答
  •  天命终不由人
    2020-12-16 03:45

    The issue you have its normal on Flutter so let's see the code.

    I guess the problem is in the constructor for the Widget, need to be like this :

    showMyDialog(BuildContext context) {
     showDialog(
      context: context,
      builder: (BuildContext context){
      return new AlertDialog(
        content: Text(
            'Message Here',
          ),
          actions: [
            FlatButton(
              child: const Text('OK'),
              onPressed: () {
                Navigator.of(context).pop(true);
              },
            ),
          ],
       );
      }
     );
    }
    

    Try this

提交回复
热议问题