I want to construct the following configuration of widgets:
and I can’t figure the code out.
I only know of Container and SizedBox as options for specifying the size of a child, but with ListView as the child, infinity for height does not work.
I can’t figure why Row doesn’t constrain eg. a SizedBox wrapper with height of infinity to the actual height that is available. Does the screen not constrain it’s content?
Update:
My code was this:
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
body: Column(
children: [
TopBar(),
Row(
children: [
myListView(),
Expanded(
child: Container(
color: Colors.black,
),
),
],
),
],
),
),
),
);
}
class myListView extends StatelessWidget {
const myListView({super.key});
@override
Widget build(BuildContext context) {
return SizedBox(
width: 200,
height: double.infinity,
child: Expanded(
child: ListView(
children: [
someListItem(),
someListItem(),
],
),
),
);
}
}
The solution in my answer is partly based on @bakboem’s answer.
2
Answers
So what turned out to work, is this:
no mediaquery, no nothing...