dev
dart 49 lines 1.41 KB
Raw
1 import 'package:flutter/material.dart';
2
3 class CakeScrollbar extends StatelessWidget {
4 CakeScrollbar({
5 required this.backgroundHeight,
6 required this.thumbHeight,
7 required this.fromTop,
8 this.rightOffset = 6,
9 this.backgroundColor,
10 this.thumbColor,
11 this.width = 6,
12 });
13
14 final double backgroundHeight;
15 final double thumbHeight;
16 final double fromTop;
17 final double width;
18 final double rightOffset;
19 final Color? backgroundColor;
20 final Color? thumbColor;
21
22 @override
23 Widget build(BuildContext context) {
24 return Positioned(
25 right: rightOffset,
26 child: Container(
27 height: backgroundHeight,
28 width: width,
29 decoration: BoxDecoration(
30 color: backgroundColor ?? Theme.of(context).colorScheme.surfaceContainerHighest,
31 borderRadius: BorderRadius.all(Radius.circular(3))),
32 child: Stack(
33 children: <Widget>[
34 AnimatedPositioned(
35 duration: Duration(milliseconds: 0),
36 top: fromTop,
37 child: Container(
38 height: thumbHeight,
39 width: width,
40 decoration: BoxDecoration(
41 color: thumbColor ?? Theme.of(context).colorScheme.primary,
42 borderRadius: BorderRadius.all(Radius.circular(3))),
43 ),
44 )
45 ],
46 ),
47 ));
48 }
49 }