/
example.dart
82 lines (79 loc) · 2.37 KB
/
example.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import 'package:flutter/material.dart';
import 'package:scroll_snap_effect/scroll_snap_effect.dart';
void main() {
runApp(
const MaterialApp(
home: ExamplePage(),
),
);
}
class ExamplePage extends StatelessWidget {
const ExamplePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Example"),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Text("scrollDirection: Axis.horizontal"),
),
const SizedBox(height: 10),
SizedBox(
height: 100,
width: double.infinity,
child: ScrollSnapEffect(
itemSize: 110,
itemCount: 10,
padding: const EdgeInsets.symmetric(horizontal: 20),
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return const Padding(
padding: EdgeInsets.only(right: 10),
child: SizedBox.square(
dimension: 100,
child: ColoredBox(
color: Colors.lightBlue,
),
),
);
},
),
),
const Padding(
padding: EdgeInsets.fromLTRB(20, 30, 20, 10),
child: Text("scrollDirection: Axis.vertical"),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: SizedBox(
height: 100,
width: 100,
child: ScrollSnapEffect(
itemSize: 110,
itemCount: 10,
scrollDirection: Axis.vertical,
itemBuilder: (context, index) {
return const Padding(
padding: EdgeInsets.only(bottom: 10),
child: SizedBox.square(
dimension: 100,
child: ColoredBox(
color: Colors.amber,
),
),
);
},
),
),
),
],
),
);
}
}