Commit 3243ebe3 authored by Taufiq Rahman's avatar Taufiq Rahman Committed by Michael Goderbauer

Tap.dart: Fixes the spacing to the right side of reason (#43246)

parent cf6a8d6a
......@@ -497,7 +497,7 @@ class TapGestureRecognizer extends BaseTapGestureRecognizer {
@protected
@override
void handleTapCancel({PointerDownEvent down, PointerCancelEvent cancel, String reason}) {
final String note = reason == '' ? reason : ' $reason';
final String note = reason == '' ? reason : '$reason ';
switch (down.buttons) {
case kPrimaryButton:
if (onTapCancel != null)
......
......@@ -380,6 +380,32 @@ void main() {
tap.dispose();
});
testGesture('onTapCancel should show reason in the proper format', (GestureTester tester) {
final TapGestureRecognizer tap = TapGestureRecognizer();
tap.onTapCancel = () {
throw Exception(test);
};
final FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
bool gotError = false;
FlutterError.onError = (FlutterErrorDetails details) {
expect(details.toString().contains('"spontaneous onTapCancel"') , isTrue);
gotError = true;
};
const int pointer = 1;
tap.addPointer(const PointerDownEvent(pointer: pointer));
tester.closeArena(pointer);
tester.async.elapse(const Duration(milliseconds: 500));
tester.route(const PointerCancelEvent(pointer: pointer));
expect(gotError, isTrue);
FlutterError.onError = previousErrorHandler;
tap.dispose();
});
testGesture('No duplicate tap events', (GestureTester tester) {
final TapGestureRecognizer tapA = TapGestureRecognizer();
final TapGestureRecognizer tapB = TapGestureRecognizer();
......
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