“_Type"不是“Widget"类型的子类型 [英] '_Type' is not a subtype of type 'Widget'
本文介绍了“_Type"不是“Widget"类型的子类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我把红屏'_Type' is not a subtype of type 'Widget' 异常在NoContentPage中我写下了完整的组件代码并调用了StatefulWidget.这段代码有什么问题.我认为这是 Flutter 中非常常见的异常.
I took the red screen '_Type' is not a subtype of type 'Widget' exception in NoContentPage I wrote down the full component code and called place into StatefulWidget. What is wrong in this code. I think it is a very common exception in the flutter.
class NoContentPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return (new Container(
width: 320.0,
child: new Column(
children: <Widget>[
Center(
child: Text(AppLocalizations.of(context).messageNoContent,
style: TextStyle(
color: Colors.black,
fontSize: 20.0,
fontWeight: FontWeight.w300,
letterSpacing: 0.3,
)))
],
),
));
}
}
叫
body: Container(
child: videos == null
? Center(child: CircularProgressIndicator())
: videos.length == 0
? NoContentPage
: ListView.builder(
itemCount: videos.length,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
playYoutubeVideo(videos[index][Video.videoUrl]);
},
child: Column(children: [
new YoutubeCard(
video: videos[index],
),
new Divider(
height: 0.0,
color: Colors.grey,
),
]));
}),
)
推荐答案
你的错误是你返回的是类型而不是给定类型的实例:
Your mistake is that you returned the type instead of the instance of a given type:
return Foo;
对
return Foo();
这篇关于“_Type"不是“Widget"类型的子类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文