-
Notifications
You must be signed in to change notification settings - Fork 74
/
flutter_staggered_grid_view.dart
121 lines (115 loc) · 3.26 KB
/
flutter_staggered_grid_view.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import 'package:flutter/material.dart';
import 'pages/aligned.dart';
import 'pages/masonry.dart';
import 'pages/quilted.dart';
import 'pages/staggered.dart';
import 'pages/staired.dart';
import 'pages/woven.dart';
class MyFlutterStaggeredGridView extends StatelessWidget {
const MyFlutterStaggeredGridView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Staggered Grid View')),
body: const Center(
child: SingleChildScrollView(
child: Column(
children: [
SizedBox(height: 10),
MenuEntry(
title: 'Staggered',
imageName: 'staggered',
destination: StaggeredPage(),
),
SizedBox(height: 10),
MenuEntry(
title: 'Masonry',
imageName: 'masonry',
destination: MasonryPage(),
),
SizedBox(height: 10),
MenuEntry(
title: 'Quilted',
imageName: 'quilted',
destination: QuiltedPage(),
),
SizedBox(height: 10),
MenuEntry(
title: 'Woven',
imageName: 'woven',
destination: WovenPage(),
),
SizedBox(height: 10),
MenuEntry(
title: 'Staired',
imageName: 'staired',
destination: StairedPage(),
),
SizedBox(height: 10),
MenuEntry(
title: 'Aligned',
imageName: 'aligned',
destination: AlignedPage(),
),
],
),
),
),
);
}
}
class MenuEntry extends StatelessWidget {
const MenuEntry({
Key? key,
required this.title,
required this.imageName,
required this.destination,
}) : super(key: key);
final String title;
final Widget destination;
final String imageName;
@override
Widget build(BuildContext context) {
return Card(
elevation: 4,
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute<void>(
builder: (context) => destination,
),
);
},
child: Stack(
children: [
Image.asset(
'assets/images/staggered_grid_view/$imageName.png',
fit: BoxFit.fill,
),
Positioned.fill(
child: FractionallySizedBox(
heightFactor: 0.25,
alignment: Alignment.bottomCenter,
child: ColoredBox(
color: Colors.black.withOpacity(0.75),
child: Center(
child: Text(
title,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
.titleLarge!
.copyWith(color: Colors.white),
),
),
),
),
),
],
),
),
);
}
}