createDeffaultThumb function
Widget
createDeffaultThumb(
- BuildContext context,
- Animation<
double> thumbAnimation, - Set<
WidgetState> widgetStates, - Color backgroundColor,
- double thickness,
- double? length,
- ScrollbarPosition scrollbarPosition,
Implementation
Widget createDeffaultThumb(BuildContext context, Animation<double> thumbAnimation, Set<WidgetState> widgetStates,
Color backgroundColor, double thickness, double? length, ScrollbarPosition scrollbarPosition) {
final thumbOffsetAnimation = Tween<Offset>(begin: const Offset(1, 0), end: Offset.zero).animate(thumbAnimation);
final thumbColor = Theme.of(context).scrollbarTheme.thumbColor ??
WidgetStateProperty.resolveWith<Color>((states) {
if (states.contains(WidgetState.dragged) || states.contains(WidgetState.pressed)) {
return backgroundColor.withOpacity(0.6);
}
if (states.contains(WidgetState.hovered)) {
return backgroundColor.withOpacity(0.5);
}
return backgroundColor.withOpacity(0.3);
});
final isVertical = scrollbarPosition == ScrollbarPosition.left || scrollbarPosition == ScrollbarPosition.right;
return SlideTransition(
position: thumbOffsetAnimation,
child: Align(
alignment: Alignment.centerRight,
child: Container(
height: isVertical ? length : thickness,
width: isVertical ? thickness : length,
color: thumbColor.resolve(widgetStates))));
}