Unverified Commit 4d38f94e authored by fzyzcjy's avatar fzyzcjy Committed by GitHub

`ModalBarrier`'s gesture recognizer does not call `invokeCallback` (#125386)

Close #125385 - please see explanations there :)

If you think this PR looks OK, I will polish it (e.g. copy-and-paste-and-modify the tests shown in #125385 into here and make CI pass)
parent 110fe75b
......@@ -394,7 +394,9 @@ class _AnyTapGestureRecognizer extends BaseTapGestureRecognizer {
@protected
@override
void handleTapUp({PointerDownEvent? down, PointerUpEvent? up}) {
onAnyTapUp?.call();
if (onAnyTapUp != null) {
invokeCallback('onAnyTapUp', onAnyTapUp!);
}
}
@protected
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart' show PointerDeviceKind, kSecondaryButton;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
......@@ -399,6 +400,29 @@ void main() {
expect(dismissCallbackCalled, true);
});
testWidgets('when onDismiss throws, should have correct context', (WidgetTester tester) async {
final FlutterExceptionHandler? handler = FlutterError.onError;
FlutterErrorDetails? error;
FlutterError.onError = (FlutterErrorDetails details) {
error = details;
};
final UniqueKey barrierKey = UniqueKey();
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: ModalBarrier(
key: barrierKey,
onDismiss: () => throw Exception('deliberate'),
),
),
));
await tester.tap(find.byKey(barrierKey));
await tester.pump();
expect(error?.context.toString(), contains('handling a gesture'));
FlutterError.onError = handler;
});
testWidgets('will not pop when given an onDismiss callback', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => const FirstWidget(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment