web_smooth_scroll 是一个专为 Flutter 设计的包,旨在提升 Web 平台上的滚动体验。它提供更平滑、更自然的滚动动画,增强视觉吸引力和用户交互性。通过优化滚动行为,它减少了卡顿,为可滚动控件带来流畅且美观的体验。该包特别针对 Web 应用程序,因为平滑滚动对于现代用户体验标准至关重要。
适合场景
增强网页应用的滚动体验
创建流畅的用户界面交互
提高网页的感知性能
添加优雅的滚动效果
优化网页应用中的滚动行为
主要特点
平滑滚动动画
Web 特定优化
所需设置最少
改进的滚动流畅性
可自定义的滚动行为
适合对象
寻求更好滚动体验的Web开发者
包含长滚动内容的应用
以设计为重点的Web应用程序
注重视觉效果的项目
带有交互式内容的 Flutter Web 项目
使用建议
主要用于网络平台
可能需要在不同浏览器上进行测试
对移动设备或桌面端的影响有限
基本滚动功能不需要
取决于浏览器对平滑滚动的支持
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Web Smooth Scroll
A package to help you provide a smoother and aesthetic scroll feeling. The motivation behind this package is, while using the official Flutter SDK the scrolling experience on web is very jerky and feels laggy to overcome it and provide more quality scrolling this package is developed.
Motivation
While I was developing my portfolio website using Flutter I faced the issue of jerky scrolling so for a research in solving it I came across this package https://pub.dev/packages/smooth_scroll_web, but it has got some issues and currently not being maintained by the author. It has issues while scrolling and also when using with scrollbars the scroll behaviour is different. Also when user uses a trackpad to scroll it'll scroll to the bottom of the screen and makes the website completely unusable. Also that package doesn't supports null safety which is supported in this package. I've developed this package to overcome all this issues. I would like to thank Dezső Csete, for this motivation and providing a base to work on.
WebSmoothScroll can be used with any scrollable widget, just pass the same scroll controller to WebSmoothScroll as well as the scrollable widget. And also specify scroll physics to NeverScrollableScrollPhysics()
There are additional optional parameters one can use
WebSmoothScroll(
controller: _scrollController,
scrollSpeed: 2.1, // additional scroll extent for smooth animation
scrollAnimationLength: 800, // duration of animation of scroll in milliseconds
curve: Curves.easeInOutCirc, // curve of the animation
child: SingleChildScrollView(
physics: constNeverScrollableScrollPhysics(),
controller: _scrollController,
child: _buildScrollableList(),
),
),
Some points to be noted
This plugin is to be used only on web and not on any other platform, you can check if platform is web and render using WebSmoothScroll else don't use this plugin.
Remember to assign physics as NeverScrollableScrollPhysics() else you won't see any change in the scrolling behaviour