modal_with_navigator.dart
2.22 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
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
class ModalWithNavigator extends StatelessWidget {
const ModalWithNavigator({Key? key}) : super(key: key);
@override
Widget build(BuildContext rootContext) {
return Material(
child: Navigator(
onGenerateRoute: (_) => MaterialPageRoute(
builder: (context2) => 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>[
MaterialButton(
onPressed: () =>
Navigator.of(rootContext).pop(),
child: Text('touch here'),
)
],
),
),
),
);
},
)),
).toList(),
),
),
),
),
),
));
}
}