简体   繁体   English

返回类型“SliverAppBar?” 不是&#39;列表<Widget> &#39;,根据闭包上下文的要求

[英]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.

相关问题 返回类型“小部件?” 不是闭包上下文所要求的“小部件” - The return type 'Widget?' isn't a 'Widget', as required by the closure's context 返回类型“_MainPage”不是闭包上下文所要求的“Widget” - The return type '_MainPage' isn't a 'Widget', as required by the closure's context 根据闭包上下文的要求,返回类型“Person”不是“Widget” - The return type 'Person' isn't a 'Widget', as required by the closure's context 根据闭包上下文的要求,返回类型“Object”不是“Widget” - The return type 'Object' isn't a 'Widget', as required by the closure's context 返回类型&#39;列表<ListTile> &#39; 不是闭包上下文所要求的 &#39;Widget&#39; - The return type 'List<ListTile>' isn't a 'Widget', as required by the closure's context 如何解决“返回类型'List<text> ? 不是闭包上下文所要求的“小部件”。”</text> - How to solve "The return type 'List<Text>?' isn't a 'Widget', as required by the closure's context." 返回类型 'Future<null> ' 不是闭包上下文所要求的“小部件”</null> - The return type 'Future<Null>' isn't a 'Widget', as required by the closure's context 错误:返回类型“CategoryState”不是“Widget”,这是闭包上下文所要求的 - error: The return type 'CategoryState' isn't a 'Widget', as required by the closure's context 错误:根据闭包上下文的要求,返回类型“NetworkImage”不是“Widget” - error: The return type 'NetworkImage' isn't a 'Widget', as required by the closure's context 错误消息:根据闭包上下文的要求,返回类型“void”不是“Widget” - Error Message: The return type 'void' isn't a 'Widget', as required by the closure's context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM