【发布时间】:2019-07-23 10:27:15
【问题描述】:
我把红屏'_Type' is not a subtype of type 'Widget' 异常在NoContentPage我写下了完整的组件代码并调用了StatefulWidget。这段代码有什么问题。我认为这是 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,
),
]));
}),
)
【问题讨论】: