get.dialog flutter code example

Example 1: flutter close dialog

showDialog(
    context: context,
    builder: (_) {
      return AlertDialog(
        title: Text('Wanna Exit?'),
        actions: [
          FlatButton(
            onPressed: () => Navigator.pop(context, false), // passing false
            child: Text('No'),
          ),
          FlatButton(
            onPressed: () => Navigator.pop(context, true), // passing true
            child: Text('Yes'),
          ),
        ],
      );
    }).then((exit) {
  if (exit == null) return;

  if (exit) {
    // user pressed Yes button
  } else {
    // user pressed No button
  }
});

Example 2: flutter modal dialog fullscreen

showDialog(        context: context,        builder: (BuildContext context) {          return Dialog(            shape: RoundedRectangleBorder(                borderRadius:                    BorderRadius.circular(20.0)), //this right here            child: Container(              height: 200,              child: Padding(                padding: const EdgeInsets.all(12.0),                child: Column(                  mainAxisAlignment: MainAxisAlignment.center,                  crossAxisAlignment: CrossAxisAlignment.start,                  children: [                    TextField(                      decoration: InputDecoration(                          border: InputBorder.none,                          hintText: 'What do you want to remember?'),                    ),                    SizedBox(                      width: 320.0,                      child: RaisedButton(                        onPressed: () {},                        child: Text(                          "Save",                          style: TextStyle(color: Colors.white),                        ),                        color: const Color(0xFF1BC0C5),                      ),                    )                  ],                ),              ),            ),          );        });

Tags:

Dart Example