Firebase 我在FlatterItemBuilder中不断遇到这个错误
这就是android studio中显示的内容构造函数返回的类型“dynamic”不是预期的类型“Widget”,并且也给了我这个参考包:flift/src/material/scaffold.dartFirebase 我在FlatterItemBuilder中不断遇到这个错误,firebase,flutter,dart,firebase-realtime-database,Firebase,Flutter,Dart,Firebase Realtime Database,这就是android studio中显示的内容构造函数返回的类型“dynamic”不是预期的类型“Widget”,并且也给了我这个参考包:flift/src/material/scaffold.dart body: new Container( child: new Column( children: <Widget>[ new Flexible( child: new Fireb
body: new Container(
child: new Column(
children: <Widget>[
new Flexible(
child: new FirebaseAnimatedList(
query: reference,
padding: const EdgeInsets.all(8.0),
reverse: true,
sort: (a, b) => b.key.compareTo(a.key),
itemBuilder: (_, DataSnapshot messageSnapshot, Animation<double> animation, int index) {
return new ChatTextController(
messageSnapshot: messageSnapshot,
animation: animation,
);
},
),
),
new Divider(height: 1.0),
new Container(
decoration:
new BoxDecoration(color: Theme.of(context).cardColor),
child: _buildTextComposer(),
),
new Builder(builder: (BuildContext context) {
_scaffoldContext = context;
return new Container(width: 0.0, height: 0.0);
})
],
),
decoration: Theme.of(context).platform == TargetPlatform.android
? new BoxDecoration(
border: new Border(
top: new BorderSide(
color: Colors.grey[200],
)))
: null,
)
body:新容器(
子:新列(
儿童:[
新柔性(
子级:新的FirebaseAnimatedList(
查询:参考,
填充:常数边集全部(8.0),
相反:是的,
排序:(a,b)=>b.key.compareTo(a.key),
itemBuilder:(uz、DataSnapshot消息快照、动画、int索引){
返回新的控制器(
messageSnapshot:messageSnapshot,
动画:动画,
);
},
),
),
新隔板(高度:1.0),
新容器(
装饰:
新的盒子装饰(颜色:主题.of(上下文).cardColor),
子项:_buildTextComposer(),
),
新建生成器(生成器:(BuildContext上下文){
_脚手架上下文=上下文;
返回新容器(宽度:0.0,高度:0.0);
})
],
),
装饰:Theme.of(context.platform==TargetPlatform.android
?新的盒子装饰(
边界:新边界(
顶部:新边界(
颜色:颜色。灰色[200],
)))
:null,
)
确保此控制器返回一个类似容器之类的小部件,而不是一个动态值:
ChatTextController(
messageSnapshot: messageSnapshot,
animation: animation,
);
ListView的itemBuilder属性总是希望其生成器函数返回UI小部件,参考
包:flift/src/material/scaffold.dart
表示您的问题与scaffold
的构造函数有关。您是否在任何特定线路上收到此错误?这是您得到的全部消息还是有更详细的错误消息?