【问题标题】:The argument type 'Widget' can't be assigned to the parameter type 'PreferredSizeWidget?'. error occurring in appBar in flutter [duplicate]参数类型“Widget”不能分配给参数类型“PreferredSizeWidget?”。颤动中的appBar发生错误[重复]
【发布时间】:2021-08-22 17:39:47
【问题描述】:

here you can see the code where error is occurring

here is the image of the function in the widget package

这个错误只发生在我的一个系统中,如果我尝试使用 appBar 的函数,它总是向我显示错误。我曾多次尝试卸载和安装 android studio,但似乎没有任何效果。

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies flutter-web flutter-test


    【解决方案1】:

    你的 aBM 应该返回一个 AppBar 类型,也在函数定义中替换

    Widget aBM 
    

    AppBar aBM
    

    【讨论】:

      【解决方案2】:

      下面的代码应该可以解决您的问题

       appBar: AppBar(
          title: Text('title'),
        ),
      

      你也可以使用flutter的PreferredSize小部件,这个小部件的高度是toolbarHeight和底部小部件的首选高度之和。

      PreferredSize(
              preferredSize: Size.fromHeight(100.0),
              child: _anyWidget
      )
      

      这应该可以解决您的错误。

      【讨论】:

        猜你喜欢
        • 2021-08-23
        • 2021-11-11
        • 1970-01-01
        • 2020-11-15
        • 2021-12-13
        • 2019-12-06
        • 2020-08-30
        • 2020-01-10
        • 2019-11-12
        相关资源
        最近更新 更多