-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Closed
flutter/engine
#49424Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.found in release: 3.16Found to occur in 3.16Found to occur in 3.16found in release: 3.18Found to occur in 3.18Found to occur in 3.18frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight
Description
Steps to reproduce
To reproduce using the sample code below (for scaling, I used MacOS trackpard):
- Tap on the view (should print
onTap
) - Zoom in and Zoom out using two fingers multiple times (see screen recording)
- Tap on the view (it would print
onScale
)- if that does not happen, repeat step 2 and zoom in then out to the max.
Screen.Recording.2023-12-29.at.11.34.17.AM.mov
Expected results
I expect GestureDetector.onTap
to be invoked for taps on the widget.
Actual results
Tapping on the widget after scaling invokes onScale...
instead of GestureDetector.onTap
.
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ScaleTapIssue(),
),
),
),
);
}
class ScaleTapIssue extends StatefulWidget {
const ScaleTapIssue({
Key? key,
}) : super(key: key);
@override
State<ScaleTapIssue> createState() => _ScaleTapIssueState();
}
class _ScaleTapIssueState extends State<ScaleTapIssue> {
var scale = 1.0;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
print('onTap');
},
onScaleUpdate: (details) {
// to avoid printing all events
if (details.scale == 1.0) {
print('onScale');
} else {
final newScale = scale - ((1 - details.scale) * 0.2);
if (newScale >= 0.1 && newScale <= 4.0) {
setState(() {
scale = newScale;
});
}
}
},
child: Center(
child: Container(
color: Colors.yellow.shade200,
height: 500,
width: 500,
child: ClipRect(
clipBehavior: Clip.hardEdge,
child: Transform.scale(
scale: scale,
child: Center(
child: Container(
color: Colors.red,
height: 50,
width: 50,
),
),
),
),
),
),
);
}
}
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.5, on macOS 12.7 21G816 darwin-x64, locale en)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.85.1)
[✓] Connected device (2 available)
[✓] Network resources
! Doctor found issues in 1 category.
Additional Details:
I have previously filed the following issue for InteractiveViewer
, and I believe this new issue is its root cause or closer to it:
p.s. I would like to mention that GestureDetector.onScale
has few other unexpected behaviors such as the conflict with onPan
and the treatment of "single finger scroll" as a scaling event. Here are some issues that I ran into while working with scaling and other gestures:
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.found in release: 3.16Found to occur in 3.16Found to occur in 3.16found in release: 3.18Found to occur in 3.18Found to occur in 3.18frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight