forked from md-siam/widget_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrollbar.dart
35 lines (32 loc) · 1 KB
/
scrollbar.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import 'package:flutter/material.dart';
class MyScrollbar extends StatelessWidget {
const MyScrollbar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.purple[100],
appBar: AppBar(title: const Text('Scrollbar')),
body: Scrollbar(
isAlwaysShown: true, // scrollbar always visitable
thickness: 10, // width of scrollbar
child: ListView.separated(
padding: const EdgeInsets.all(20),
itemCount: 25,
separatorBuilder: (context, index) => const SizedBox(height: 10),
itemBuilder: (context, index) => buildCard(index + 1),
),
),
);
}
Widget buildCard(int index) => Card(
margin: EdgeInsets.zero,
elevation: 5.0,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'Item $index',
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
);
}