I am getting this error. I read that with this error the problem is Expanded
and solution to use it with a column
, row
or flex
. But in my code, I use it that way, so there should be no error. Please help me.
My code:
List<DataColumn> initHeader() {
List<DataColumn> header = [];
for (var i = 0; i < widget.headerList.length; i++) {
header.add(new DataColumn(
label: Flexible(
child: Text(
widget.headerList[i].name,
),
)));
}
return header;
}
lets use this code its will solve your peoblem
Widget build(BuildContext context) {
return Scaffold(
body: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
TextFormField(
//ontroller: skuController,
textInputAction: TextInputAction.done,
decoration: InputDecoration(
//labelText: AppLocalizations.instance.text('Scan'),
suffixIcon: IconButton(
onPressed: () {},
icon: Icon(Icons.search),
),
),
),
//ableReport(this.getProduct()),
Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 25),
child: ElevatedButton(
onPressed: () {},
child: Text('Submit'),
),
)),
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 25),
child: ElevatedButton(
onPressed: () {},
child: Text(
'Check items',
textAlign: TextAlign.center,
),
),
)),
],
),
],
),
));
}
}
I changed Flexible
to Container
and it works good without error.
Before:
List<DataColumn> initHeader() {
List<DataColumn> header = [];
for (var i = 0; i < widget.headerList.length; i++) {
header.add(new DataColumn(
label: Flexible(
child: Text(
widget.headerList[i].name,
),
)));
}
return header;
}
After:
List<DataColumn> initHeader() {
List<DataColumn> header = [];
for (var i = 0; i < widget.headerList.length; i++) {
header.add(new DataColumn(
label: Container(
child: Text(
widget.headerList[i].name,
),
)));
}
return header;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.