I can't figure out how to do this layout in Flutter. What I'm trying to achieve is:
- I have a column, containing a fixed height child (title Text widget) and two Expanded widgets. I'm using expanded because I want each to share half the remaining screen.
- When orientation changes to landscape, there is not enough room to properly show the contents of the expanded widgets. So what I want is to apply a minimum height on these 2 widgets, and for it to become scrollable.
I hope that makes sense - I have no idea how to implement this. I've tried lots of combinations of Expanded, Flexible, Column, SingleChildScrollView, min column axis size etc. but everything I try results in some kind of infinite height exception. Is this even possible?
Here's some example code: the following works fine. How to implement scroll and minimum height on the two placeholders?
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
children: <Widget>[
Text("Title"),
// I need to apply a minimum height on these two widgets,
// and it should be scrollable if necessary:
Expanded(
child: Placeholder(),
),
Expanded(
child: Placeholder(),
)
],
),
),
);
}
}