I have a DefaultTabController
and I have a method that returns List<PreferredSizeWidget>
which are the AppBar
's of pages. I want them to watch a state in a ChangeNotifier
and therefore I want to wrap them inside of a Consumer
. When I try to do so I get an error like this:
"The argument type 'Widget' can't be assigned to the parameter type 'PreferredSizeWidget'."
How can I fix this?
Thanks and regards.
The error comes from the appBar
's parameter of Scaffold
requiring a PreferredSizeWidget
. I can think of two solutions :
Consumer
with a PreferredSize
and use Size.fromHeight()
as preferredSize
. That is if the height is constant amongst your appbars.appBar
parameter altogether by wrapping your Scaffold
's body with an Expanded
inside a Column
, and making the Consumer
its first child.