In my homepage I have a column an a row inside it.And wrap them expanded widget as you can see .Everything is ok
This is Homepage
class MyHome extends StatelessWidget {
const MyHome({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
children: [
Row(
children: [
Expanded(flex: 2, child: Text("something")),
Expanded(flex: 1, child: Text("some")),
],
)
],
)),
);
}
}
But if I create a stateless widget which has nothing but a TextFomField.and change this line from this
Expanded(flex: 1, child: Text("some")),
to this
Expanded(flex: 1, child: Asd()),
then I get this exception "RenderFlex object was given an infinite size during layout".
So I tried to use flutter inspector to fix the problem .And this is how its looked like
And this is the Asd screen which has nothing except for one textbox
return Scaffold(body: TextFormField(),);
Can you help plase
CodePudding user response:
You don't have to use multiple scaffold on the same page.You can remove scaffold from Asd
widget.
class Asd extends StatelessWidget {
const Asd({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextFormField();
}
}
Another solution but dont prefer:
Also, the issue is happening because of infinite height of Asd
you can provide fixed height on widget.
Expanded(
flex: 1,
child: SizedBox(
height: 64,
child: Asd(),
),
)