flutter_scroll_to_top
A wrapper to show a scroll to top prompt to the user on scrollable widgets.
Installing
Add the following dependency to your pubspec.yaml
file:
Import the package
ScrollWrapper
Just wrap the scrollable widget you want to show the scroll to top prompt over with a ScrollWrapper
, and supply the ScrollController
of the scrollable widget to the wrapper.
Customisation
You can pass the following parameters to customise the prompt accordingly
promptScrollOffset
- At what scroll offset to show the prompt on.promptAlignment
- Where on the widget to align the prompt.promptDuration
- Duration it takes for the prompt to come into view/vanish.promptAnimationCurve
- Animation Curve that the prompt will follow when coming into view.promptAnimationType
-PromptAnimation
that the prompt follows when animating. Has three options,fade
,scale
andsize
.scrollToTopDuration
- Duration it takes for the page to scroll to the top on prompt button press.scrollToTopCurve
- Animation Curve for scrolling to the top.promptTheme
- You can passPromptButtonTheme
to modify the prompt button further. It has the following parameters:padding
- Padding around the prompt button.iconPadding
- Padding around the icon inside the button.icon
- The icon inside the button.color
- Color of the prompt button.
Custom Prompt Widget
You can replace the default prompt widget with a widget of your choosing by passing it off in the promptReplacementBuilder
parameter.
NestedScrollView Implementation
The implementation is similar, just wrap your scrollable body with the ScrollWrapper
and pass off the controller of the parent NestsedScrollView
to the wrapper.