[英]The return type 'SliverAppBar?' isn't a 'List<Widget>', as required by the closure's context
//I do not know why here is an error I wrote the class, then the function, and when I called, I returned the return. //不知道为什么这里报错我写的是类,然后是函数,调用的时候就返回了。
class WhatsAppHomeState extends State<WhatsAppHome>
with SingleTickerProviderStateMixin {
late TabController tabController;
late Map<String, SliverAppBar> appBarList;
String _currentAppBar = 'mainAppBar';
@override
void initState() {
// TODO: implement initState
super.initState();
tabController = new TabController(initialIndex: 1, length: 4, vsync: this);
SliverAppBar mainAppBar = new SliverAppBar(...);
appBarList = <String, SliverAppBar>{
'mainAppBar': mainAppBar,
'searchAppBar': mainAppBar
};
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return appBarList[_currentAppBar]];//I do not know why here is an error
},..
. . .
. .
.
headerSliverBuilder
needs a list of widgets: headerSliverBuilder
需要一个小部件列表:
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
appBarList[_currentAppBar]]
];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.