I want to make a simple calculator application in Flutter. After three days of work, I couldn't get it to behave as designed at different resolutions and screen sizes.
The home screen is divided into 3 areas:
- A top area, where the operations history is shown
- A middle area, for the calculator display of the current computation
- A bottom area for the keyboard.
This screenshot of the design can be helpful to understand the global idea
The display and keyboard areas have the constraints of minHeight and maxHeight and all the free top space of the screen is used to shows the operation history (who has only a minHeight constraints).
The display and keyboard areas try to use their maxHeight until the screen height is small enough to activate the minHeight of the top area.
As the height of the screen continues to shrink, the display and keyboard areas shrink proportionally until they reach their minHeight.
I've code this toy example but it's not has the desired behavior:
class HomePage extends StatelessWidget {
const HomePage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: Column(children: <Widget>[
Expanded(
child: ConstrainedBox(
constraints:
BoxConstraints(maxHeight: double.infinity, minHeight: 20),
child: Container(
color: Colors.red,
),
),
),
Expanded(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: 100, minHeight: 50),
child: Container(
color: Colors.blue,
),
)),
Expanded(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: 400, minHeight: 300),
child: Container(
color: Colors.green,
),
)),
]));
}
}
Can anyone guide me to achieve the described behavior of the three areas as the screen height change?
Thank you very much!
Regards