Reputation: 51
I updated the flutter channel, issued Internet permission in the manifest(I saw answers that helped)
I think the problem is related to Expanded, but I'm not sure, in the debug and release works well, after the build stops
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.deepPurple,
title: Text('Справочник'),
),
body: ListView.separated(
itemCount: data.length,
itemBuilder: (context, index) {
return Container(
height: 50,
alignment: Alignment.center,
child: Expanded(
child: GestureDetector(
child: Text('${data[index].name}', textAlign: TextAlign.center,),
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => FoodByGroup(dataFood: data[index].foods,)));
},
),
),
);
},
separatorBuilder: (BuildContext context, int index) => const Divider(),
),
);
}
} ```
Upvotes: 1
Views: 671
Reputation: 742
Take good notice of what your terminal is telling you. DO NOT ignore warnings about widget build order, It will work in debug mode most of the time but show you grey screen in release.
The problem here is that you can only use expanded as a direct child of flex widgets. Expanded need flex ancestor so basically these: Row, Column, or Flex.
Upvotes: 0
Reputation: 2327
Remove Expanded from container,The problem is you can't use Expand in child,means that An Expanded widget must be a descendant or parent
example:
Expanded(
child: MyWidget(),
),
Row
Row(
children: [
Expanded(
child: MyWidget(),
),
Expanded(
child:Text("Text Widget"),
),
],
)
in Column
Column(
children: [
Expanded(
child: MyWidget(),
),
Expanded(
child:Text("Text Widget"),
),
],
),
not like this
Container(
child: Expanded(
child: MyWidget(),
),
)
Upvotes: 2