-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flutter_web] Navigation_NavigationBar
- Loading branch information
Showing
2 changed files
with
43 additions
and
29 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
.../flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Navigation_NavigationBar.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Navigation_NavigationBar()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Navigation_NavigationBar extends StatelessWidget { | ||
Navigation_NavigationBar({super.key}); | ||
|
||
final selected = 0.signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
List<({NavigationDestination destination, Widget page})> destinations = [ | ||
( | ||
destination: const NavigationDestination(icon: Icon(Icons.explore), label: 'Explore'), | ||
page: Container(width: double.infinity, height: double.infinity, color: Colors.blue.shade100, child: const Text("Explore")), | ||
), | ||
( | ||
destination: const NavigationDestination(icon: Icon(Icons.commute), label: 'Commute'), | ||
page: Container(width: double.infinity, height: double.infinity, color: Colors.green.shade100, child: const Text("Commute")), | ||
), | ||
]; | ||
return Watch(builder: (context) { | ||
return SizedBox( | ||
width: double.infinity, | ||
height: 200, | ||
child: Scaffold( | ||
body: destinations[selected.value].page, | ||
bottomNavigationBar: NavigationBar( | ||
onDestinationSelected: (newSelection) => selected.value = newSelection, | ||
selectedIndex: selected.value, | ||
destinations: destinations.map((e) => e.destination).toList(), | ||
), | ||
), | ||
); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters