createDeffaultThumb function

Widget createDeffaultThumb(
  1. BuildContext context,
  2. Animation<double> thumbAnimation,
  3. Set<WidgetState> widgetStates,
  4. Color backgroundColor,
  5. double thickness,
  6. double? length,
  7. 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))));
}