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