modal_complex_all.dart
2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
class ComplexModal extends StatelessWidget {
const ComplexModal({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Material(
child: WillPopScope(
onWillPop: () async {
bool shouldClose = true;
await showCupertinoDialog(
context: context,
builder: (context) => CupertinoAlertDialog(
title: Text('Should Close?'),
actions: <Widget>[
CupertinoButton(
child: Text('Yes'),
onPressed: () {
shouldClose = true;
Navigator.of(context).pop();
},
),
CupertinoButton(
child: Text('No'),
onPressed: () {
shouldClose = false;
Navigator.of(context).pop();
},
),
],
));
return shouldClose;
},
child: Navigator(
onGenerateRoute: (_) => MaterialPageRoute(
builder: (context) => Builder(
builder: (context) => CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
leading: Container(), middle: Text('Modal Page')),
child: SafeArea(
bottom: false,
child: ListView(
shrinkWrap: true,
controller: ModalScrollController.of(context),
children: ListTile.divideTiles(
context: context,
tiles: List.generate(
100,
(index) => ListTile(
title: Text('Item'),
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) =>
CupertinoPageScaffold(
navigationBar:
CupertinoNavigationBar(
middle: Text('New Page'),
),
child: Stack(
fit: StackFit.expand,
children: <Widget>[],
))));
},
)),
).toList(),
),
),
),
),
),
),
),
);
}
}