Skip to content

Instantly share code, notes, and snippets.

@arnaudruffin
Created August 8, 2024 14:11
Show Gist options
  • Save arnaudruffin/67df7607d85254d94b2145ab637ae1a4 to your computer and use it in GitHub Desktop.
Save arnaudruffin/67df7607d85254d94b2145ab637ae1a4 to your computer and use it in GitHub Desktop.
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