Staggered Grid View can achieve sizing and everything, but it always starts placing items from the top, just under app bar. How to achieve to add that text (Found 10 items for example) and then start displaying items in grid view?
Asked
Active
Viewed 460 times
-1
1 Answers
0
If you look at the GridView
of the image, you will find a pattern.
On itemCount:
pass itemLength+1
. This extra 1
will be help to insert Text
.
TO build this GridView use StaggeredGridView.countBuilder
StaggeredGridView.countBuilder(
crossAxisCount: 2,
shrinkWrap: true,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
itemCount: 10,
itemBuilder: (context, index) {
return index == 0
? Center(child: Text("Item s "))
: Container(
color: index.isEven ? Colors.amber : Colors.deepPurple,
alignment: Alignment.center,
child: Text("$index s"),
);
},
staggeredTileBuilder: (index) {
return index == 0
? StaggeredTile.count(1, .3) //For Text
: StaggeredTile.count(1, 1); // others item
},
),
TO learn more about flutter_staggered_grid_view.
Pattern draw sorry for the bad drawing, hope you got the concept now.

Md. Yeasin Sheikh
- 54,221
- 7
- 29
- 56
-
Excuse me on not being clear enough and for not forming question a little better. This is actually my first question on Stack Overflow. :) Such a clear answer. I had my first experience with staggered grid view last night and I was super tired su I couldn't even read documentation. I had built the same screen without using this package but it's much cleaner and more flexible with staggered grid view. – fokes777 Oct 29 '21 at 23:25