main.dart
1.82 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
import 'package:example/route_example_page.dart';
import 'package:example/sheet_example_page.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:sheet/route.dart';
void main() => runApp(MyApp());
final goRouter = GoRouter(routes: [
GoRoute(
path: '/',
pageBuilder: (context, state) =>
MaterialExtendedPage<void>(child: const BottomNavigationScaffold()),
),
]);
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp.router(
theme: ThemeData(platform: TargetPlatform.iOS),
debugShowCheckedModeBanner: false,
title: 'BottomSheet Modals',
routerConfig: goRouter,
);
}
}
class BottomNavigationScaffold extends StatefulWidget {
const BottomNavigationScaffold({super.key});
@override
State<BottomNavigationScaffold> createState() =>
_BottomNavigationScaffoldState();
}
class _BottomNavigationScaffoldState extends State<BottomNavigationScaffold> {
int _currentNavitagionIndex = 0;
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Expanded(
child: IndexedStack(
index: _currentNavitagionIndex,
children: const <Widget>[
SheetExamplesPage(),
RouteExamplePage(),
],
),
),
BottomNavigationBar(
currentIndex: _currentNavitagionIndex,
onTap: (int value) {
setState(() {
_currentNavitagionIndex = value;
});
},
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.pages), label: 'Sheet'),
BottomNavigationBarItem(icon: Icon(Icons.route), label: 'Route'),
])
],
);
}
}