base_scaffold.dart
1.78 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
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ExampleTile extends StatelessWidget {
const ExampleTile({
super.key,
required this.title,
required this.page,
this.leading,
});
ExampleTile.sheet(this.title, Widget sheet, {this.leading})
: page = BaseScaffold(title: Text(title), sheet: sheet);
final String title;
final Widget page;
final Widget? leading;
@override
Widget build(BuildContext context) {
return ListTile(
leading: leading,
title: Text(title),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => page,
),
),
);
}
}
class BaseScaffold extends StatelessWidget {
const BaseScaffold({
super.key,
this.sheet,
this.title,
this.appBarTrailingButton,
});
final Widget? sheet;
final Widget? title;
final Widget? appBarTrailingButton;
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: CupertinoNavigationBar(
transitionBetweenRoutes: false,
middle: title ?? const Text('Example'),
trailing: appBarTrailingButton,
),
backgroundColor: Colors.grey[200],
body: Stack(
children: <Widget>[
Container(
// color: Colors.,
height: double.infinity,
width: double.infinity,
alignment: Alignment.center,
child: ListView.builder(
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text('Item $index'),
onTap: () {},
);
}),
),
if (sheet != null) sheet!
],
),
);
}
}