Created
August 8, 2024 14:11
-
-
Save arnaudruffin/67df7607d85254d94b2145ab637ae1a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'test nav rail', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
colorSchemeSeed: Colors.blue, | |
), | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('test nav rail'), | |
), | |
body: NavigationRail( | |
selectedIndex : 0, | |
elevation: 2, | |
// to force small nav destinations to fill space | |
minWidth: 105, | |
// show label for all items | |
groupAlignment: -1.0, | |
// topAlignment | |
destinations: [ | |
NavigationRailDestination( | |
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), | |
icon: Icon(Icons.info), | |
label: Text('a'), | |
), | |
NavigationRailDestination( | |
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), | |
icon: Icon(Icons.info), | |
label: Text('b'), | |
) | |
], | |
onDestinationSelected: (int index) { | |
print("onDestinationSelected $index"); | |
}, | |
), | |
), | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment