Commit 69ce7f69 authored by Adam Barth's avatar Adam Barth

runApp inside onPressed throws an exception (#4419)

We were trying to unregister the pointer route twice. Now we only unregister it
once.

Fixes #4341
parent 5af67e15
......@@ -212,7 +212,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
@override
void rejectGesture(int pointer) {
ensureNotTrackingPointer(pointer);
stopTrackingPointer(pointer);
}
@override
......
......@@ -114,16 +114,12 @@ abstract class OneSequenceGestureRecognizer extends GestureRecognizer {
///
/// Use [startTrackingPointer] to add the routes in the first place.
void stopTrackingPointer(int pointer) {
GestureBinding.instance.pointerRouter.removeRoute(pointer, handleEvent);
_trackedPointers.remove(pointer);
if (_trackedPointers.isEmpty)
didStopTrackingLastPointer(pointer);
}
/// Calls [stopTrackingPointer] if the pointer with the given ID is being tracked by this recognizer.
void ensureNotTrackingPointer(int pointer) {
if (_trackedPointers.contains(pointer))
stopTrackingPointer(pointer);
if (_trackedPointers.contains(pointer)) {
GestureBinding.instance.pointerRouter.removeRoute(pointer, handleEvent);
_trackedPointers.remove(pointer);
if (_trackedPointers.isEmpty)
didStopTrackingLastPointer(pointer);
}
}
/// Stops tracking the pointer associated with the given event if the event is
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('runApp inside onPressed does not throw', (WidgetTester tester) async {
await tester.pumpWidget(
new Material(
child: new RaisedButton(
onPressed: () {
runApp(new Center(child: new Text('Done')));
},
child: new Text('GO')
)
)
);
await tester.tap(find.text('GO'));
expect(find.text('Done'), findsOneWidget);
});
}
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