How To Constraint The Width Of A GridView Widget In Flutter
I've been trying for two days to add a fixed width to a Grid View in flutter but I couldn't.
I tried adding width or Box Constraint to a parent container but it didn't work.
I am building a web app so the screen width is often wider than a smartphone's.
this is how I want it to look like:
constraint the width of the GridView Widget to have a max width of 1000 as an example.
if you face any issue with centering the parent container just rap it with a Center widget and that should work
Here you can use
crossAxisCount property to add no of items in row. Then give the fixed to its child by wrapping it in a container.
Container( width: 100, // HERE YOU CAN ADD THE WIDTH child: GridView.builder( physics: NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: list.length, scrollDirection: Axis.vertical, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( childAspectRatio: 1, crossAxisCount: 4, // HERE YOU CAN ADD THE NO OF ITEMS PER LINE mainAxisSpacing: 5, crossAxisSpacing: 5, ), itemBuilder: _getListItemTile))
- → 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?