Anyone please give some information why this is happening?
When I try to add a class AppBarDesign which implements appBar flutter is gi
If you get the error
The argument type x can't be assigned to the parameter type 'PreferredSizeWidget'.
Just wrap x in the PreferredSize widget.
Example:
appBar: AppBar(
bottom: Column(
children: [
new TabBar(
tabs: [
new Tab(icon: new Icon(Icons.directions_car)),
new Tab(icon: new Icon(Icons.directions_transit)),
new Tab(
icon: new Icon(Icons.airplanemode_active),
)
],
),
],
),
Here I get the error: The argument type 'Column' can't be assigned to the parameter type 'PreferredSizeWidget'.
Solution:
Click on Column
Click on light bulb
Choose Wrap with Widget
Replace widget with PreferredSize
Add a PreferredSize attribute, such as preferredSize: Size.fromHeight(100.0),
Result:
appBar: AppBar(
bottom: PreferredSize(
preferredSize: Size.fromHeight(100.0),
child: Column(
children: [
new TabBar(
tabs: [
new Tab(icon: new Icon(Icons.directions_car)),
new Tab(icon: new Icon(Icons.directions_transit)),
new Tab(
icon: new Icon(Icons.airplanemode_active),
)
],
),
],
),
),