flutter - 底部溢出 418 像素的 RenderFlex
问题描述
在此之前,一切都在 Container 中,没有任何问题,但动画出现错误。谁能帮忙?)
return AnimatedContainer(
curve: Curves.easeInCirc,
duration: Duration(milliseconds: 200),
height: _heightWidget,
decoration: isTaped
? BoxDecoration(
border: Border(
bottom: BorderSide(
width: 0.0, color: Color.fromRGBO(131, 134, 163, 0.52)),
),
)
: BoxDecoration(
border: Border(
bottom: BorderSide(
width: 1.0, color: Color.fromRGBO(131, 134, 163, 0.52)),
),
),
child: Expanded(
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Container(
height: 43.0,
width: 60.0,
color: widget.dateBackgroundColor != null
? widget.dateBackgroundColor
: Colors.green,
child: Center(
child: MaterialButton(
onPressed: () {
_pageController.previousPage(
duration: widget.pageChangeDuration != null
? widget.pageChangeDuration
: Duration(microseconds: 500),
curve: Curves.easeIn,
);
},
child: Icon(
widget.backwardIcon == null
? Icons.arrow_back
: widget.backwardIcon,
color: Colors.black,
),
),
),
),
Expanded(
child: Container(
height: 43.0,
color: widget.dateBackgroundColor != null
? widget.dateBackgroundColor
: Colors.red,
child: Padding(
padding: EdgeInsets.only(top: 0.0, bottom: 0.0),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
onTap: () {
setState(() {
isTaped = !isTaped;
isTaped
? _heightWidget = 464.0
: _heightWidget = 44.0;
});
},
child: Row(
children: <Widget>[
Image.asset('assets/icons/calendar.png'),
SizedBox(
width: 10.0,
),
Text(
checkDateToday(DateFormat(
widget.displayDateFormat == null
? widget.displayDateFormat
: "dd.MM.yyyy")
.format(_selectedDate)),
style: widget.dateStyle != null
? widget.dateStyle
: TextStyle(
color: Colors.black,
fontSize: 14.0,
fontWeight: FontWeight.w100,
),
),
],
)),
],
)),
),
),
),
Container(
height: 43.0,
width: 60.0,
color: widget.dateBackgroundColor != null
? widget.dateBackgroundColor
: Colors.red,
child: Center(
child: MaterialButton(
onPressed: () {
_pageController.nextPage(
duration: widget.pageChangeDuration != null
? widget.pageChangeDuration
: Duration(milliseconds: 700),
curve: Curves.easeIn,
);
},
child: Icon(
widget.forwardIcon == null
? Icons.arrow_forward
: widget.forwardIcon,
color: Colors.black,
),
),
),
),
],
),
Container(
decoration: BoxDecoration(
border: isTaped
? Border(
top: BorderSide(
width: 1.0,
color: Color.fromRGBO(131, 134, 163, 0.52)),
)
: null,
),
padding: EdgeInsets.only(left: 0, right: 0),
child: isTaped
? Column(
children: <Widget>[
SizedBox(height: 12.0),
Container(
child: SizedBox(
height: 21.0,
child: GridView.count(
crossAxisCount: 7,
primary: false,
children: weekDaysOnTop,
)),
),
Row(
children: <Widget>[
Container(
margin: EdgeInsets.only(
left: 25, top: 10, bottom: 0),
child: Text(
_currentMonth,
style: TextStyle(
color: Color.fromRGBO(83, 83, 83, 1),
fontWeight: FontWeight.bold,
fontSize: 24.0,
),
)),
],
),
Container(
child: _calendarCarousel,
),
Row(
children: <Widget>[
Container(
margin: EdgeInsets.only(
left: 25, top: 10, bottom: 0),
child: Text(
_nextMonth,
style: TextStyle(
color: Color.fromRGBO(83, 83, 83, 1),
fontWeight: FontWeight.bold,
fontSize: 24.0,
),
)),
],
),
],
)
: null),
Expanded(
child: PageView.builder(
controller: _pageController,
scrollDirection: Axis.horizontal,
itemCount: _totalPages,
onPageChanged: (direction) => _onPageChange(direction),
itemBuilder: (context, index) {
return _buildPage(index);
})),
],
),
),
);
════════ 小部件库捕获的异常═════════════════════════════␕══以下应用父数据时抛出断言。:ParentDataWidget 使用不正确。
ParentDataWidget Expanded(flex: 1) 想要将 FlexParentData 类型的 ParentData 应用于 RenderObject,该 RenderObject 已设置为接受不兼容类型 BoxParentData 的 ParentData。
通常,这意味着 Expanded 小部件具有错误的祖先 RenderObjectWidget。通常,扩展小部件直接放置在 Flex 小部件内。有问题的 Expanded 当前放置在 Padding 小部件中。
接收到不兼容的父数据的 RenderObject 的所有权链是:Column ← Expanded ← Padding ← DecoratedBox ← ConstrainedBox ← Container ← AnimatedContainer ← ScrollingDayCalendar ← DecoratedBox ← ConstrainedBox ←⋯</p>
解决方案
您不能在 AnimatedContainer 中使用扩展,因为它是扩展 Row、Column 或 Flex 的子项的小部件,以便子项填充可用空间。尝试在列内使用它。并用mainAxisSize: MainAxisSize.max
推荐阅读
- postgresql - 在 Kubernetes 中部署 postgres
- python - “或”在 python lambda 中表现异常
- java - 线程“主”java.lang.NoSuchMethodError 中的异常:'void Car.setYear(java.lang.Integer)'
- c - 有没有办法加速 openMP
- machine-learning - 是否可以在训练之前和训练期间修改 OpenAI 健身房状态?
- django - 一个 Django 模板中的多个表单
- oracle - 在这个简单的组中,错误的起别名是错误的原因吗?
- svg - 在 SVG 绘图中将多个子绘图缩放为相同大小
- python - 如何拆分列表并获取python中的最后一个值
- java - 如何在 Java 中使用 Webclient 添加 CA 证书和客户端证书