Skip to content

Commit 7c1e17e

Browse files
committed
Bump to version 0.2.6
1 parent d16e280 commit 7c1e17e

File tree

4 files changed

+158
-2
lines changed

4 files changed

+158
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.6
2+
### Fixed
3+
* Fix a bug where items are built only once.
4+
15
## 0.2.5
26
### Changed
37
* Use the new SliverWithKeepAliveWidget.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ In the `pubspec.yaml` of your flutter project, add the following dependency:
2828
```yaml
2929
dependencies:
3030
...
31-
flutter_staggered_grid_view: "^0.2.5"
31+
flutter_staggered_grid_view: "^0.2.6"
3232
```
3333
3434
In your library add the following import:

example/lib/main_issue_21.dart

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
3+
4+
class DeviceTypeList {
5+
String deviceTypeName = 'test';
6+
}
7+
8+
class DeviceTypeItem extends StatefulWidget {
9+
final List<DeviceTypeList> deviceTypes;
10+
final Function onSelected;
11+
12+
DeviceTypeItem(this.deviceTypes, this.onSelected);
13+
14+
@override
15+
_DeviceTypeItemState createState() => _DeviceTypeItemState();
16+
}
17+
18+
class _DeviceTypeItemState extends State<DeviceTypeItem> {
19+
int _selectIndex = -1;
20+
21+
_DeviceTypeItemState();
22+
23+
_selectDevice(int index) {
24+
setState(() {
25+
_selectIndex = index;
26+
});
27+
// onSelected(deviceTypes[_selectIndex].deviceTypeName);
28+
}
29+
30+
_tmpData() {
31+
return List.generate(
32+
10,
33+
(int index) => GestureDetector(
34+
child: Container(
35+
child: Text(widget.deviceTypes[0].deviceTypeName),
36+
color: _selectIndex == index ? Colors.blue : Colors.brown,
37+
padding: EdgeInsets.only(top: 4, bottom: 4),
38+
alignment: Alignment.center,
39+
),
40+
onTap: () => _selectDevice(index),
41+
));
42+
}
43+
44+
@override
45+
Widget build(BuildContext context) {
46+
return Container(
47+
padding: EdgeInsets.all(12),
48+
// child: GridView.count(
49+
// crossAxisCount: 3,
50+
// children: _tmpData(),
51+
// shrinkWrap: true,
52+
// ),
53+
54+
child: StaggeredGridView.count(
55+
crossAxisCount: 3,
56+
children: _tmpData(),
57+
staggeredTiles: List.generate(10, (int index) => StaggeredTile.fit(1)),
58+
shrinkWrap: true,
59+
),
60+
);
61+
}
62+
}
63+
64+
// import 'package:flutter/material.dart';
65+
// import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
66+
67+
// void main() => runApp(MyApp());
68+
69+
// class MyApp extends StatelessWidget {
70+
// @override
71+
// Widget build(BuildContext context) {
72+
// return MaterialApp(
73+
// title: 'StaggeredGridView Demo',
74+
// theme: ThemeData(
75+
// primarySwatch: Colors.blue,
76+
// ),
77+
// home: MyScreen(),
78+
// );
79+
// }
80+
// }
81+
82+
// class MyScreen extends StatefulWidget {
83+
// @override
84+
// _MyScreenState createState() => new _MyScreenState();
85+
// }
86+
87+
// class _MyScreenState extends State<MyScreen> {
88+
// int _count = 0;
89+
90+
// @override
91+
// Widget build(BuildContext context) {
92+
// return Scaffold(
93+
// body: GridTest(_count, _count),
94+
// floatingActionButton: FloatingActionButton(
95+
// child: Icon(Icons.add),
96+
// onPressed: () {
97+
// setState(() {
98+
// _count++;
99+
// });
100+
// },
101+
// ),
102+
// );
103+
// }
104+
// }
105+
106+
// class GridTest extends StatelessWidget {
107+
// GridTest(this.count, this.value);
108+
// final int count;
109+
// final int value;
110+
111+
// @override
112+
// Widget build(BuildContext context) {
113+
// return GridView.builder(
114+
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
115+
// crossAxisCount: 3,
116+
// crossAxisSpacing: 2,
117+
// mainAxisSpacing: 2,
118+
// ),
119+
// itemCount: count,
120+
// itemBuilder: (context, index) {
121+
// return Container(
122+
// color: Colors.blue,
123+
// child: Text('$value'),
124+
// );
125+
// },
126+
// );
127+
// }
128+
// }
129+
130+
// class StaggeredTest extends StatelessWidget {
131+
// StaggeredTest(this.count, this.value);
132+
// final int count;
133+
// final int value;
134+
135+
// @override
136+
// Widget build(BuildContext context) {
137+
// return StaggeredGridView.countBuilder(
138+
// itemCount: count,
139+
// crossAxisCount: 3,
140+
// crossAxisSpacing: 2,
141+
// mainAxisSpacing: 2,
142+
// addAutomaticKeepAlives: false,
143+
// staggeredTileBuilder: (index) => StaggeredTile.extent(1, 30),
144+
// itemBuilder: (context, index) {
145+
// return Container(
146+
// color: Colors.green,
147+
// child: Text('$value'),
148+
// );
149+
// },
150+
// );
151+
// }
152+
// }

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_staggered_grid_view
22
description: A Flutter staggered grid view
3-
version: 0.2.5
3+
version: 0.2.6
44
author: Romain Rastel <[email protected]>
55
homepage: https://github.com/letsar/flutter_staggered_grid_view
66
dependencies:

0 commit comments

Comments
 (0)