Ad
How To Achieve Scrollable Grid View Exactly Like In This Photo Using Flutter
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?
Ad
Answer
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.
Ad
source: stackoverflow.com
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?
Ad