Skip to content

GestureDetector defers onTap to next screen tap #41233

@lukepighetti

Description

@lukepighetti

So basically if you tap GestureDetector, it will defer its events until the next event is fired. This is a very serious regression unless I'm misunderstanding something.

Here's a little rx style marble diagram:

input:    1-2-3-4-5-6
expected: 1-2-3-4-5-6
actual:   --1-2-3-4-5
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v1.10.5, on Mac OS X 10.14.6 18G87, locale en-US)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.38.1)
[✓] Connected device (1 available)

• No issues found!
import 'package:flutter/material.dart';

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

class _MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Material(
        child: Row(
          children: [1, 2, 3].map(
            (value) {
              /// 1. Tap once on any of these
              /// 2. Observe that no print statement occurs
              /// 3. Tap anywhere on the screen
              /// 4. Observe that the previously expected print statement occurs
              ///
              /// TLDR: print statements are delayed one tap, even if the
              ///       last tap is not on any of these GestureDetectors
              return GestureDetector(
                onTap: () => print(value),
                child: Container(
                  color: Colors.red.shade100,
                  margin: EdgeInsets.all(8),
                  alignment: Alignment.center,
                  child: Text(value.toString()),
                  width: 60,
                ),
              );
            },
          ).toList(),
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: gesturesflutter/packages/flutter/gestures repository.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