我在NoContentPage中将红色屏幕“ _Type”不是“ Widget”类型的子类型异常记录下来,写下了完整的组件代码并将其放置在StatefulWidget中。这段代码有什么问题。我认为这是一个非常普遍的例外。
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,
)))
],
),
));
}
}
Run Code Online (Sandbox Code Playgroud)
叫
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,
),
]));
}),
)
Run Code Online (Sandbox Code Playgroud)
Rém*_*let 12
您的错误是您返回了该类型,而不是给定类型的实例:
return Foo;
Run Code Online (Sandbox Code Playgroud)
与
return Foo();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1025 次 |
| 最近记录: |