我试图像这样给人一种扩展的效果。
isOpened == true
? AnimatedContainer(
duration: Duration(seconds: 2),
curve: Curves.fastOutSlowIn,
child: Container(
width: !_mapViewController.cardExpanded()
? MediaQuery.of(context).size.width * 0.00
: MediaQuery.of(context).size.width * 0.85,
height: !_mapViewController.cardExpanded()
? MediaQuery.of(context).size.height * 0.00
: MediaQuery.of(context).size.height * 0.28,
child: Column(
children: [
Container(height: 100, width: 100, color: Colors.orange),
ListWidget(),
],
),
),
)
: Container(),我的列表小部件是
@override
Widget build(BuildContext context) {
return ListView(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
children: [
RaisedButton(
onPressed: () {
print('heey');
},
child: Text(
'heuhaiuh',
),
),
Container(
height: 35,
width: 35,
),
Container(
height: 35,
width: 35,
color: Colors.green,
),
Container(
height: 35,
width: 35,
color: Colors.yellow,
),
Container(
height: 35,
width: 35,
color: Colors.orange,
),
],
);
}我收到成堆的错误,说
flutter: Another exception was thrown: RenderConstrainedBox does not meet its constraints.
flutter: Another exception was thrown: RenderDecoratedBox does not meet its constraints.
flutter: Another exception was thrown: Null check operator used on a null value
flutter: Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 1704 pos 12: '!_debugDoingThisLayout': is not true.它在没有ListWidget()的情况下运行良好。如果我将Column()替换为ListWidget(),那么它也可以工作得很好。在这种情况下,如何将ListView()放入Column()中?
而且,动画效果不是很好。容器只是在没有动画的情况下出现。想知道我怎么也能调整这个吗?
发布于 2021-01-04 04:39:32
由于您的ListView滚动方向是水平的,因此必须指定其父对象的高度。将ListView包装在Container中,并为容器指定高度
return Container(
height: PREFERRED_HEIGHT,
child: ListView(
// ...
),
);https://stackoverflow.com/questions/65554643
复制相似问题