我在ListView中有一个ListView,而内部的ListView不知道它应该有多高,所以我必须给它一个特定的高度,比如SizedBox。然而,问题是我实际上想让内部的ListView收缩包装,这样它就不会在父ListView中滚动/占用不必要的空间。
提前感谢
发布于 2017-08-23 09:13:08
这听起来像是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),
),
],
),
),
));
}https://stackoverflow.com/questions/45774203
复制相似问题