搜索插件、代码仓与 APP 分类

插件详情v1.0.8

smooth_scroll_multiplatform

一个用于可滚动控件的包装器,可在所有平台上实现鼠标平滑滚动。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1320
喜欢数
30
Pub 分数
130

安装插件

flutter pub add smooth_scroll_multiplatform

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个增强可滚动控件的 Flutter 包,可在所有平台上实现平滑、鼠标驱动的滚动。它包装现有的可滚动组件(如 ListView 或 ScrollViewController),在使用鼠标时提供流畅、连续的滚动体验,从而提升桌面和网页应用的可用性。该包确保无论目标平台如何,行为都保持一致,非常适合需要精确导航的应用程序。它利用原生输入处理,提供响应迅速且自然的滚动效果。

适合场景

  • 桌面应用程序导航
  • Web 应用平滑滚动
  • 跨平台 UI 一致性
  • 增强鼠标输入的用户体验
  • 数据密集型界面中的滚动

主要特点

  • 跨平台的平滑滚动
  • 以鼠标为中心的滚动优化
  • 与现有可滚动组件的无缝集成
  • 支持所有主要平台
  • 最小配置要求

适合对象

  • 面向多平台的开发者
  • 包含大量可滚动内容的应用
  • 面向桌面和网络的 Flutter 项目
  • 以用户体验为中心的界面设计
  • 需要精细滚动行为的项目

使用建议

  • 可能不会影响基于触摸的滚动
  • 需要鼠标输入才能充分发挥效果
  • 对移动平台的影响有限
  • 最适合非移动设备的用例
  • 大型列表上的潜在性能开销

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Multiplatform Smooth Scroll

A fork of the dyn_mouse_scroll package, including Wizzel1's fixes and my own fixes; Provides wrapper for scrollable widgets that enables smooth scrolling with a mouse wheel, trackpad or touch screen on all platforms; This fork fixes all issues regarding trackpad, mouse/trackpad switching and animations, fixing the slippery effect when changing scroll direction; The fork also changes the default mouse scroll animation to look smoother; Additionally, it allows to change the scroll speed, on top of the duration and animation curve.

First gif: Scrolling slowly.
Second gif: Scrolling quickly (flick scroll).
Third gif: Mobile drag scroll detected, physics change.

Features

  • Animate smooth scroll based on speed of user's scroll.
  • Automatically detect if the wrong ScrollPhysics is being used and update using provider.
  • Adjust the duration of your scroll events.
  • Choose what mobile physics you would like to use.

Basic Usage

DynMouseScroll(
  builder: (context, controller, physics) => ListView(
    controller: controller,
    physics: physics,
    children: ...
    )
)

With additional settings:

DynMouseScroll(
  durationMS: 500,
  scrollSpeed: 4.4,
  animationCurve: Curves.easeOutQuart,
  builder: (context, controller, physics) => ListView(
    controller: controller,
    physics: physics,
    children: ...
    )
)

Problem:

Flutter does not animate smooth scrolls for pointers, causing choppy experiences for the end user. One package, web_smooth_scroll, attempts to fix this problem by disabling default scrolling entirely (mobile can't drag now) and listening for pointer events to animate the scroll controller that can only move at one speed.

Solution:

To allow mobile default scrolling to still be accessible I detect the user's platform and automatically update if the detection was wrong. When the user scrolls, the 'futurePosition' variable is updated and the animation is started I set the mobile scroll physics as the default one, switching to desktop scroll physics as the mouse wheel scroll is initiated and only starting the animation after the widget is rebuilt; the desktop scroll physics then takes priority over mobile physics, switching back to mobile physics only after the last scroll animation has ended, only if no new scroll wheel action had been initiated in the meantime.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目