I have the following code for a layout.
@override
Widget build(BuildContext context) {
return Material(
child: Scaffold(
// resizeToAvoidBottomPadding: false,
// resizeToAvoidBottomInset: false,
appBar: PreferredSize(
preferredSize: Size.fromHeight(70),
child: AppBar(
centerTitle: true,
title: AutoSizeText(
meal['name'],
minFontSize: 30,
maxFontSize: 50,
),
backgroundColor: Colors.black,
elevation: 1,
actions: <Widget>[
IconButton(
icon: Icon(Icons.add),
onPressed: () => null,
),
],
),
),
body: Builder(
builder: (context) {
return Container(
color: Colors.black,
alignment: Alignment.center,
child: FractionallySizedBox(
widthFactor: 0.85,
child: Container(
child: Column(
children: <Widget>[
Spacer(flex: 1,),
Container(
margin: EdgeInsets.only(bottom: 50),
child: Column(
children: <Widget>[
Container(
decoration: BottomWhiteDecoration(6.0),
padding: EdgeInsets.only(bottom: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Servings: 1',
style: TextStyle(color: Colors.white),
),
],
),
),
Container(
child: Column(
children: <Widget>[
RowNutrimentalInfo('Calories', meal['calories'], showGram: false),
RowNutrimentalInfo('Protein', meal['macros']['proteins']),
RowNutrimentalInfo('Carbs', meal['macros']['carbs']),
RowNutrimentalInfo('Fat', meal['macros']['fats']),
],
),
)
],
),
),
Spacer(flex: 2,),
Container(
child: Column(
children: <Widget>[
Form(
key: this._mealFormKey,
child: Row(
children: <Widget>[
Expanded(
flex: 10,
child: TextFormField(...),
),
Spacer(flex: 1,),
Expanded(
flex: 10,
child: TextFormField(...),
),
],
),
),
FractionallySizedBox(
widthFactor: .50,
child: OutlineButton(
borderSide: BorderSide(color: Colors.white),
color: Colors.black,
onPressed: _eatMeal,
child: Padding(
padding: EdgeInsets.all(20),
child: Text('Ok',
style: TextStyle(color: Colors.white)),
),
),
)
],
),
),
Spacer(flex: 2,),
],
),
),
),
);
},
),
),
);
}
However when I start typing in one of the text fields the keyboard causes the layout to overflow on the bottom as shown in the following image.
The following is the error I'm getting and how it is displayed on the the phone. Any ideas to get around this? I've seen similar questions, solutions like setting resizeToAvoidBottomPadding: false, don't work for me as the keyboard still covers the text input.
The following assertion was thrown during layout:
A RenderFlex overflowed by 45 pixels on the bottom.
The relevant error-causing widget was:
Column file:///C:/Users/bolon/StudioProjects/macro_counter/lib/Meal.dart:92:26
The overflowing RenderFlex has an orientation of Axis.vertical.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen.
If the content is legitimately bigger than the available space, consider clipping it with a ClipRect
widget before putting it in the flex, or using a scrollable container rather than a Flex, like a
ListView.

