Tom*_*652 5 dart flutter flutter-sliver sliver-grid
我遇到以下错误:
======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
Updated layout information required for RenderIndexedSemantics#f51aa NEEDS-LAYOUT to calculate semantics.
'package:flutter/src/rendering/object.dart':
Failed assertion: line 2658 pos 12: '!_needsLayout'
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md
When the exception was thrown, this was the stack:
#2 RenderObject._getSemanticsForParent (package:flutter/src/rendering/object.dart:2658:12)
#3 RenderObject._getSemanticsForParent.<anonymous closure> (package:flutter/src/rendering/object.dart:2680:61)
#4 Iterable.forEach (dart:core/iterable.dart:257:30)
#5 RenderSliverVariableSizeBoxAdaptor.visitChildren (package:flutter_staggered_grid_view/src/rendering/sliver_variable_size_box_adaptor.dart:296:29)
#6 RenderObject.visitChildrenForSemantics (package:flutter/src/rendering/object.dart:2765:5)
...
====================================================================================================
Run Code Online (Sandbox Code Playgroud)
我想知道这是什么意思以及这种情况通常发生在什么时候?
我正在使用该flutter_staggered_grid_view: ^0.4.0 包。
如果需要,我会创建一个 GitHub 问题。
编辑:这是一段代码来突出显示该问题:
我的主要小部件是由以下方式呈现的:
StaggeredGridView.countBuilder(
itemBuilder: (BuildContext context, int index) {
return MyCustomItem();
},
padding: EdgeInsets.only(left: Constants.maxWidth*2/100, right: Constants.maxWidth*2/100,
bottom: Constants.maxHeight*10/100 + 65), // home button size + margin bottom
crossAxisCount: 2,
mainAxisSpacing: 20,
crossAxisSpacing: Constants.maxWidth*2/100,
itemCount: 30,
physics: BouncingScrollPhysics(),
staggeredTileBuilder: (int index) {
return StaggeredTile.fit(1);
},
),
Run Code Online (Sandbox Code Playgroud)
以及MyCustomItem组成 List 的每个项目的 Widget :
Column(
children: [
GestureDetector(
child:
Container(
margin: (widget.index == 0 || widget.index == 1) ? EdgeInsets.only(top: Constants.maxHeight*6/100+60) : EdgeInsets.all(0),
//width: postWidth,
// TODO : post height
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(20)),
child: Image.asset("assets/images/test.jpg"), // TODO
),
),
onTap: () {
// TODO
},
onDoubleTap: () {
// TODO
},
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(child:
Container(
margin: EdgeInsets.only(top: 10, bottom: 3),
width: 35,
height: 35,
),
onTap: () {
// TODO
},
),
Flexible(child:
Container(
width: Constants.maxWidth*25/100,
child:
Text(
"tessssst",
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Color(resColors.getShadow()),
),
maxLines: 1,
),
),
),
],
),
Spacer(),
Container(
margin: EdgeInsets.only(right: Constants.maxWidth * 2 / 100),
child: Column(children: [
Container(
margin: EdgeInsets.only(bottom: 3, top: 10),
child: InkWell(
onTap: () {
// TODO
},
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
),
),
Text("1029"),
]),
),
Container(
child: Column(children: [
Container(
margin: EdgeInsets.only(bottom: 3, top: 10, right: Constants.maxWidth/100),
child: InkWell(
onTap: () => {},// TODO
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
),
),
Text("Test"),
]),
),
],
)
],
);
Run Code Online (Sandbox Code Playgroud)
我想补充一点,如果MyCustomItem只是一个Text小部件,我就没有错误。
| 归档时间: |
|
| 查看次数: |
2233 次 |
| 最近记录: |