diff --git a/packages/flutter/lib/src/scheduler/binding.dart b/packages/flutter/lib/src/scheduler/binding.dart index 8820c7cf04121dfa94735ade14ca78d47f0ce35e..3a2dc87e8780397247a0e4fe714bb1d25cde5e16 100644 --- a/packages/flutter/lib/src/scheduler/binding.dart +++ b/packages/flutter/lib/src/scheduler/binding.dart @@ -9,6 +9,7 @@ import 'dart:ui' show AppLifecycleState, DartPerformanceMode, FramePhase, FrameT import 'package:collection/collection.dart' show HeapPriorityQueue, PriorityQueue; import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; import 'debug.dart'; import 'priority.dart'; @@ -1310,6 +1311,10 @@ mixin SchedulerBinding on BindingBase { return true; }()); } + + void setDVsyncSwitch(bool isEnable) { + SystemChannels.nativeVsync.send({"isEnable": isEnable}); + } } /// The default [SchedulingStrategy] for [SchedulerBinding.schedulingStrategy]. diff --git a/packages/flutter/lib/src/services/system_channels.dart b/packages/flutter/lib/src/services/system_channels.dart index c69c7e5e77d026093d5b27d5ae9efcd05b6a7195..13531d3fb1a4298dbe7f5badd37fdd216015b42f 100644 --- a/packages/flutter/lib/src/services/system_channels.dart +++ b/packages/flutter/lib/src/services/system_channels.dart @@ -465,4 +465,9 @@ class SystemChannels { /// /// * [DefaultPlatformMenuDelegate], which uses this channel. static const MethodChannel menu = OptionalMethodChannel('flutter/menu'); + + static const BasicMessageChannel nativeVsync = BasicMessageChannel( + 'flutter/nativevsync', + StandardMessageCodec(), + ); } diff --git a/packages/flutter/lib/src/widgets/scroll_position.dart b/packages/flutter/lib/src/widgets/scroll_position.dart index db363517c3725f43296b0b9f76c3efe738020c20..e9f8de32d28901276c202bff540d976ea6c5d967 100644 --- a/packages/flutter/lib/src/widgets/scroll_position.dart +++ b/packages/flutter/lib/src/widgets/scroll_position.dart @@ -916,6 +916,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { /// /// This also saves the scroll offset using [saveScrollOffset]. void didEndScroll() { + SchedulerBinding.instance.setDVsyncSwitch(false); activity!.dispatchScrollEndNotification(copyWith(), context.notificationContext!); saveOffset(); if (keepScrollOffset) { diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index 158228c23a7e22304b690e6cdba16e5efcebcade..1415fc363ea1907bf7fcd690fabc99a2b496f039 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -709,6 +709,7 @@ class ScrollableState extends State with TickerProviderStateMixin, R // triggers a new activity to begin. assert(_drag == null); _drag = position.drag(details, _disposeDrag); + SchedulerBinding.instance.setDVsyncSwitch(false); assert(_drag != null); assert(_hold == null); } @@ -723,6 +724,7 @@ class ScrollableState extends State with TickerProviderStateMixin, R // _drag might be null if the drag activity ended and called _disposeDrag. assert(_hold == null || _drag == null); _drag?.end(details); + SchedulerBinding.instance.setDVsyncSwitch(true); assert(_drag == null); }