43 lines
1.2 KiB
Dart
43 lines
1.2 KiB
Dart
![]() |
import 'package:flutter/material.dart';
|
||
|
|
||
|
import 'package:go_router/go_router.dart';
|
||
|
|
||
|
class ScaffoldWithBottomNavigationBar extends StatelessWidget {
|
||
|
const ScaffoldWithBottomNavigationBar({
|
||
|
required this.navigationShell,
|
||
|
Key? key,
|
||
|
}) : super(key: key ?? const ValueKey<String>('ScaffoldWithNavBar'));
|
||
|
|
||
|
final StatefulNavigationShell navigationShell;
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
body: SafeArea(child: navigationShell),
|
||
|
bottomNavigationBar: BottomNavigationBar(
|
||
|
fixedColor: Theme.of(context).colorScheme.onPrimary,
|
||
|
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||
|
items: const <BottomNavigationBarItem>[
|
||
|
BottomNavigationBarItem(
|
||
|
icon: Icon(Icons.list),
|
||
|
label: 'Widget Wall',
|
||
|
),
|
||
|
BottomNavigationBarItem(
|
||
|
icon: Icon(Icons.dashboard),
|
||
|
label: 'Dashboard',
|
||
|
),
|
||
|
],
|
||
|
currentIndex: navigationShell.currentIndex,
|
||
|
onTap: (int index) => _onTap(context, index),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
void _onTap(BuildContext context, int index) {
|
||
|
navigationShell.goBranch(
|
||
|
index,
|
||
|
initialLocation: index == navigationShell.currentIndex,
|
||
|
);
|
||
|
}
|
||
|
}
|