Ad
How To Implement GridView In Column In Flutter?
i have a SingleChildScrollView that contains a form and Form cotains a Column. now i want to use GridView like this:
return SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color(0xffffffff),
borderRadius: BorderRadius.all(Radius.circular(20))),
margin: EdgeInsets.only(
right: 25, left: 25, top: MediaQuery.of(context).size.height * .12),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new InputFieldArea(
icon: Icons.person,
controller: _payValController,
lable: 'مبلغ',
maxLength: 9,
validator: (value) {
if (value.isEmpty) {
return 'لطفا این فرم را پر کنید';
}
return null;
},
textInputType: TextInputType.number,
),
_imagesAssets.length > 0
? new SizedBox(
child: _buildGridView(),
)
: Container(),
_submit(context),
],
),
),
));
this is my gridView:
Widget _buildGridView() {
return GridView.count(
crossAxisCount: 2,
padding: EdgeInsets.all(10),
children: List.generate(_imagesAssets.length, (index) {
Asset asset = _imagesAssets[index];
return AssetThumb(
asset: asset,
width: 100,
height: 100,
);
}),
);
}
but i got this render error: RenderBox was not laid out: RenderRepaintBoundary#3ec8a relayoutBoundary=up18 NEEDS-PAINT 'package:flutter/src/rendering/box.dart': Failed assertion: line 1930 pos 12: 'hasSize' any idea will be greate
Ad
Answer
In GridView use these below parameters
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
or you can give fix height to your grid view widget.
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