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 :
- You can wrap your
preferredSize. That is if the height is constant amongst your appbars.
- You can avoid using the
appBarparameter altogether by wrapping your
Scaffold‘s body with an
Column, and making the
Consumerits first child.
Answered By – MickaelHrndz
Answer Checked By – Cary Denson (FlutterFixes Admin)