-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Use case
In my Flutter App, I have a NavigationDrawer with NavigationDrawerDestinations. Ideally, I would like the 'Settings' destination to be at the bottom of the drawer, sticking to the lower edge of the screen. In regular ListViews or Columns, this can be done with some Align widget. However, You can not use NavigationDrawerDestinations if their parent is not a NavigationDrawer. Hence, I cannot align the settings destination to the bottom of the screen.
A code example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
final String title;
const MyHomePage({
Key? key,
required this.title,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text("My App"),
),
drawer: const NavigationDrawer(
children: [
NavigationDrawerDestination(
icon: Icon(Icons.home),
label: Text("Home"),
),
NavigationDrawerDestination(
icon: Icon(Icons.settings),
label: Text("This works"),
),
// Align(
// alignment: Alignment.bottomLeft,
// child: NavigationDrawerDestination(
// icon: Icon(Icons.settings),
// label: Text("This does not work"),
// )
// )
]
),
body: const Center(
child: Text('Home'),
),
);
}
}
The commented bit shows what I would like to do, but which does not work.
Proposal
It would be great if NavigationDrawerDestination widgets could be used anywhere as long as there is a NavigationDrawer above them in the tree. Aside from Align widgets, this could also be useful for ExpansionTiles, such as used in the drawer of the Firebase Console:
This proposal is related to #127621 but I want to be able to put NavigationDrawerDestination widgets inside the Align/ExpansionTile/whatever widgets
