Skip to content

Make NavigationDrawer more customizable #135750

@WesselvanDam

Description

@WesselvanDam

Is there an existing issue for this?

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:

image

This proposal is related to #127621 but I want to be able to put NavigationDrawerDestination widgets inside the Align/ExpansionTile/whatever widgets

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions