Skip to content

It's possbile to drag Drawers with the mouse #100321

@justinmc

Description

@justinmc

Currently, Drawers can be dragged open and closed with the mouse:

screenrecording.mp4

There is no way to disable this behavior. We should either provide a way to disable this, or if no one wants this behavior at all, remove it completely for mouse interactions.

To reproduce

  1. Run an app with a Drawer, such as the one given below.
  2. Make sure you have a mouse connected.
  3. Drag from the left side of the screen with the mouse.

Expected: Nothing happens
Actual: The menu is revealed. It can also be dragged shut.

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

void main() {
  runApp(MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        platform: TargetPlatform.macOS,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Drawer Demo'),
        ),
        drawer: Drawer(
          child: ListView(
            padding: EdgeInsets.zero,
            children: const <Widget>[
              DrawerHeader(
                decoration: BoxDecoration(
                  color: Colors.blue,
                ),
                child: Text(
                  'Drawer Header',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 24,
                  ),
                ),
              ),
              ListTile(
                leading: Icon(Icons.message),
                title: Text('Messages'),
              ),
              ListTile(
                leading: Icon(Icons.account_circle),
                title: Text('Profile'),
              ),
              ListTile(
                leading: Icon(Icons.settings),
                title: Text('Settings'),
              ),
            ],
          ),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            CupertinoTextField(
              maxLines: 3,
            ),
            SizedBox(height: 32.0),
            TextField(
              maxLines: 3,
              decoration: InputDecoration(
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(30.0),
                  gapPadding: 0.0,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projecta: desktopRunning on desktopf: gesturesflutter/packages/flutter/gestures repository.f: material designflutter/packages/flutter/material repository.found in release: 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13frameworkflutter/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