Unverified Commit ef803a2b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[framework] use platform touchslop on Android (#97971)

parent 38ea38a0
......@@ -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;
});
}
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