[framework] use platform touchslop on Android (#97971)
This commit is contained in:
@@ -15,6 +15,7 @@ import 'basic.dart';
|
||||
import 'focus_manager.dart';
|
||||
import 'framework.dart';
|
||||
import 'gesture_detector.dart';
|
||||
import 'media_query.dart';
|
||||
import 'notification_listener.dart';
|
||||
import 'primary_scroll_controller.dart';
|
||||
import 'restoration.dart';
|
||||
@@ -399,6 +400,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
|
||||
late ScrollBehavior _configuration;
|
||||
ScrollPhysics? _physics;
|
||||
ScrollController? _fallbackScrollController;
|
||||
MediaQueryData? _mediaQueryData;
|
||||
|
||||
ScrollController get _effectiveScrollController => widget.controller ?? _fallbackScrollController!;
|
||||
|
||||
@@ -452,6 +454,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
_mediaQueryData = MediaQuery.maybeOf(context);
|
||||
_updatePosition();
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
@@ -565,7 +568,8 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
|
||||
..minFlingVelocity = _physics?.minFlingVelocity
|
||||
..maxFlingVelocity = _physics?.maxFlingVelocity
|
||||
..velocityTrackerBuilder = _configuration.velocityTrackerBuilder(context)
|
||||
..dragStartBehavior = widget.dragStartBehavior;
|
||||
..dragStartBehavior = widget.dragStartBehavior
|
||||
..gestureSettings = _mediaQueryData?.gestureSettings;
|
||||
},
|
||||
),
|
||||
};
|
||||
@@ -585,7 +589,8 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
|
||||
..minFlingVelocity = _physics?.minFlingVelocity
|
||||
..maxFlingVelocity = _physics?.maxFlingVelocity
|
||||
..velocityTrackerBuilder = _configuration.velocityTrackerBuilder(context)
|
||||
..dragStartBehavior = widget.dragStartBehavior;
|
||||
..dragStartBehavior = widget.dragStartBehavior
|
||||
..gestureSettings = _mediaQueryData?.gestureSettings;
|
||||
},
|
||||
),
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' show Brightness, DisplayFeature, DisplayFeatureState, DisplayFeatureType;
|
||||
import 'dart:ui' show Brightness, DisplayFeature, DisplayFeatureState, DisplayFeatureType, GestureSettings, ViewConfiguration;
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -914,4 +914,13 @@ void main() {
|
||||
expect(subScreenMediaQuery.highContrast, true);
|
||||
expect(subScreenMediaQuery.displayFeatures, <DisplayFeature>[cutoutDisplayFeature]);
|
||||
});
|
||||
|
||||
testWidgets('MediaQuery.enableDeviceGestureSettings allows disabling gesture settings', (WidgetTester tester) async {
|
||||
tester.binding.window.viewConfigurationTestValue = const ViewConfiguration(
|
||||
gestureSettings: GestureSettings(physicalDoubleTapSlop: 100, physicalTouchSlop: 100),
|
||||
);
|
||||
|
||||
expect(MediaQueryData.fromWindow(tester.binding.window).gestureSettings.touchSlop, closeTo(33.33, 0.1)); // Repeating, of course
|
||||
tester.binding.window.viewConfigurationTestValue = null;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user