Skip to content

Scaling a widget also scales its drag gestures #31958

@tvolkert

Description

@tvolkert

Steps to reproduce

Run the following app, and scroll the list of integers by dragging up on the box.

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    title: 'Scaling drag destures is bad',
    home: Scaffold(
      body: Center(
        child: SizedBox(
          width: 240,
          height: 240,
          child: FittedBox(
            fit: BoxFit.fill,
            child: DecoratedBox(
              decoration: BoxDecoration(
                border: Border.all(color: Colors.grey),
                borderRadius: BorderRadius.all(Radius.circular(5)),
                color: Colors.white,
              ),
              child: Padding(
                padding: EdgeInsets.all(1),
                child: ClipRRect(
                  borderRadius: BorderRadius.all(Radius.circular(4)),
                  child: SizedBox(
                    width: 38,
                    height: 38,
                    child: Center(
                      child: ListWheelScrollView(
                        itemExtent: 15,
                        children: <Widget>[
                          ...Iterable<int>.generate(100).map<Widget>((int index) {
                            return Text('$index');
                          }),
                        ],
                      ),
                    ),
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    ),
  ));
}

Expected behavior

You expect the item being scrolled to follow your finger.

Actual behavior

The item being scrolled scrolls much faster than your finger moves, because the widget is being scaled 6x, and so the scrolling happens 6x as fast (because the drag gesture is also getting scaled 6x).

Metadata

Metadata

Assignees

No one assigned

    Labels

    frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions