Skip to content

ListTileTheme not respected in a scaffold's drawer option #106303

@BananaMasterz

Description

@BananaMasterz

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Click the menu button on the top left cornet to open the drawer
  3. Look at the shape of the ListTile

Expected results:
I expected the shape of the ListTile in the drawer parameter of the Scaffold, to be the same as the one in the body of the scaffold, as I specifically set
style: ListTileStyle.list

and NOT

style: ListTileStyle.drawer

Actual results:

Rectangular ListTile shape.
The TextStyle seems to be respected in the same style parameter of the ListTile but not the shape.
So now I'm forced to redefine the shape parameter in every ListTile inside the drawer parameter of the scaffold

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      theme: ThemeData(
        useMaterial3: true,
        primarySwatch: Colors.blue,
        hoverColor: Colors.black.withOpacity(0.1),
        scrollbarTheme: const ScrollbarThemeData(mainAxisMargin: 16),
        listTileTheme: ListTileThemeData(
          selectedTileColor: Colors.blue.withOpacity(.3),
          selectedColor: Theme.of(context).textTheme.bodyMedium!.color,
          style: ListTileStyle.list,
          shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.all(
              Radius.circular(16),
            ),
          ),
        ),
      ),
      home: Scaffold(
        drawer: const Padding(
          padding: EdgeInsets.all(8.0),
          child: MyDrawerWidget(),
        ),
        appBar: AppBar(title: const Text(_title)),
        body: const Padding(
          padding: EdgeInsets.all(8.0),
          child: MyDrawerWidget(),
        ),
      ),
    );
  }
}

class MyDrawerWidget extends StatefulWidget {
  const MyDrawerWidget({Key? key}) : super(key: key);

  @override
  State<MyDrawerWidget> createState() => _MyDrawerWidgetState();
}

class _MyDrawerWidgetState extends State<MyDrawerWidget> {
  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: Column(
        children: [
          ListTile(
            style: ListTileStyle.list,
            selected: true,
            title: const Text('Home'),
            onTap: () {},
          ),
          ListTile(
            style: ListTileStyle.list,
            title: const Text('Contact'),
            onTap: () {},
          )
        ],
      ),
    );
  }
}

Note: This seems similar to this issue #67371 but it was neither specific nor followed-up by the commentors.

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.found in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1frameworkflutter/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 version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions