When a list is scrolling, children can't be tapped (#5222)
This commit is contained in:
@@ -652,7 +652,10 @@ class ScrollableState<T extends Scrollable> extends State<T> {
|
||||
key: _gestureDetectorKey,
|
||||
gestures: buildGestureDetectors(),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: buildContent(context)
|
||||
child: new IgnorePointer(
|
||||
ignoring: _controller.isAnimating,
|
||||
child: buildContent(context)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
28
packages/flutter/test/widget/scrollable_fling_test.dart
Normal file
28
packages/flutter/test/widget/scrollable_fling_test.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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_test/flutter_test.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('fling and tap', (WidgetTester tester) async {
|
||||
List<String> log = <String>[];
|
||||
|
||||
List<Widget> textWidgets = <Widget>[];
|
||||
for (int i = 0; i < 250; i++)
|
||||
textWidgets.add(new GestureDetector(onTap: () { log.add('tap $i'); }, child: new Text('$i')));
|
||||
await tester.pumpWidget(new Block(children: textWidgets));
|
||||
|
||||
expect(log, equals(<String>[]));
|
||||
await tester.tap(find.byType(Scrollable));
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
expect(log, equals(<String>['tap 18']));
|
||||
await tester.fling(find.byType(Scrollable), new Offset(0.0, -200.0), 1000.0);
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
expect(log, equals(<String>['tap 18']));
|
||||
await tester.tap(find.byType(Scrollable));
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
expect(log, equals(<String>['tap 18']));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user