Skip to content

NavigationDrawerDestination backgroundColor obscures interaction states #160109

@LukasMirbt

Description

@LukasMirbt

Steps to reproduce

  1. Run the code sample
  2. Press the menu button (upper left corner)
  3. Press/long-press the second destination
  4. Note that the interaction states in the second destination are not visible
  5. Remove the backgroundColor from the NavigationDrawerDestination
  6. Note that the interaction states are present again

Expected results

Interaction states (for example a touch ripple, hover state and focused state) should be present when interacting with the NavigationDrawerDestination after having specified backgroundColor.

Actual results

The background color obscures interaction states.

Since the NavigationDrawerDestination uses navigationDrawerTheme.backgroundColor when backgroundColor is null, specifying backgroundColor in NavigationDrawerThemeData also causes this issue.

Additionally, the background color extends outside of the shape of the NavigationDrawerDestination, all the way to the edges of the NavigationDrawer which is surprising.

Code sample

Code sample
// ignore_for_file: prefer_const_constructors
// ignore_for_file: prefer_const_literals_to_create_immutables

import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        drawer: NavigationDrawer(
          children: [
            NavigationDrawerDestination(
              icon: Icon(Icons.home),
              label: Text('First destination'),
            ),
            NavigationDrawerDestination(
              backgroundColor: Colors.grey.shade300,
              icon: Icon(Icons.bug_report),
              label: Text('Second destination'),
            ),
          ],
        ),
      ),
    );
  }
}

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.27.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-SE)
    • Flutter version 3.27.0 on channel stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8495dee1fd (25 hours ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.found in release: 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions