Erorr in code While building AppBar

appBar: buildAppBarWidget(),
gives error stating:
The argument type ‘Widget’ can’t be assigned to the parameter type ‘PreferredSizeWidget?’

Type your question above this line.


Hi @Shree_Mahadik,
The problem you are facing is is because the AppBar widget of the material library is of the PreferredSizeWidget class and not as a Widget. This happened in the newer version of Flutter. We will look into this issue.
Thank you for pointing it out

I solved it by replacing “Widget” to “Static”.
Hope this solution helps.

Another way to fix it is return PreferredSizeWidget class instead of Widget class

PreferredSizeWidget buildAppBarWidget()