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

This commit is contained in:
Taufiq Rahman
2019-11-07 04:48:43 +06:00
committed by Michael Goderbauer
parent cf6a8d6a47
commit 3243ebe3ee
2 changed files with 27 additions and 1 deletions

View File

@@ -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)

View File

@@ -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();