I have a ListView inside a ListView and the inner ListView doesn't know how height it should be so I have to give it a specific height with for example a SizedBox. However the problem is that I actually want the inner ListView to shrink wrap so that it wont scroll/take unnecessary space within the parent ListView.
Thanks in advance
This sounds like a good use case for CustomScrollView
.
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
home: new Scaffold(
body: new CustomScrollView(
slivers: [
new SliverToBoxAdapter(
child: new Container(height: 100.0, color: Colors.blueAccent),
),
new SliverList(
delegate: new SliverChildListDelegate(
new List<Widget>.generate(10, (int index) {
return new Text(
'Item $index',
style: new TextStyle(fontSize: 42.0),
);
}),
),
),
new SliverToBoxAdapter(
child: new Container(height: 100.0, color: Colors.tealAccent),
),
],
),
),
));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With