popup flutter

Solutions on MaxInterview for popup flutter by the best coders in the world

showing results for - "popup flutter"
Elizabeth
04 Apr 2016
1Future<void> _showMyDialog() async {
2  return showDialog<void>(
3    context: context,
4    barrierDismissible: false, // user must tap button!
5    builder: (BuildContext context) {
6      return AlertDialog(
7        title: const Text('AlertDialog Title'),
8        content: SingleChildScrollView(
9          child: ListBody(
10            children: const <Widget>[
11              Text('This is a demo alert dialog.'),
12              Text('Would you like to approve of this message?'),
13            ],
14          ),
15        ),
16        actions: <Widget>[
17          TextButton(
18            child: const Text('Approve'),
19            onPressed: () {
20              Navigator.of(context).pop();
21            },
22          ),
23        ],
24      );
25    },
26  );
27}
Flavien
15 Nov 2020
1   import 'package:flutter/material.dart';
2
3void main() {
4  runApp(new MaterialApp(home: new MyApp()));
5}
6
7class MyApp extends StatefulWidget {
8  @override
9  _MyAppState createState() => _MyAppState();
10}
11
12class _MyAppState extends State<MyApp> {
13  final _formKey = GlobalKey<FormState>();
14
15  @override
16  Widget build(BuildContext context) {
17    return Scaffold(
18      appBar: AppBar(
19        title: Text("Flutter"),
20      ),
21      body: Center(
22        child: RaisedButton(
23          onPressed: () {
24            showDialog(
25                context: context,
26                builder: (BuildContext context) {
27                  return AlertDialog(
28                    content: Stack(
29                      overflow: Overflow.visible,
30                      children: <Widget>[
31                        Positioned(
32                          right: -40.0,
33                          top: -40.0,
34                          child: InkResponse(
35                            onTap: () {
36                              Navigator.of(context).pop();
37                            },
38                            child: CircleAvatar(
39                              child: Icon(Icons.close),
40                              backgroundColor: Colors.red,
41                            ),
42                          ),
43                        ),
44                        Form(
45                          key: _formKey,
46                          child: Column(
47                            mainAxisSize: MainAxisSize.min,
48                            children: <Widget>[
49                              Padding(
50                                padding: EdgeInsets.all(8.0),
51                                child: TextFormField(),
52                              ),
53                              Padding(
54                                padding: EdgeInsets.all(8.0),
55                                child: TextFormField(),
56                              ),
57                              Padding(
58                                padding: const EdgeInsets.all(8.0),
59                                child: RaisedButton(
60                                  child: Text("Submitß"),
61                                  onPressed: () {
62                                    if (_formKey.currentState.validate()) {
63                                      _formKey.currentState.save();
64                                    }
65                                  },
66                                ),
67                              )
68                            ],
69                          ),
70                        ),
71                      ],
72                    ),
73                  );
74                });
75          },
76          child: Text("Open Popup"),
77        ),
78      ),
79    );
80  }
81}
82