
The AppBarDesign can't be assigned to the parameter type 'PreferredSizeWidget'
SHARE :
Daftar Isi :
Explanation:
The error occurs when attempting to assign an AppBarDesign object to a parameter that expects a 'PreferredSizeWidget' type. This type mismatch prevents the assignment and triggers the error.
Resolution:
To fix this error, ensure that the assigned object matches the expected parameter type. Consider using a widget that implements the 'PreferredSizeWidget' interface or has a similar structure.
Example Code Fixing :
Scaffold(
appBar: MyAppBar(),
)
...
class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
@override
Size get preferredSize => const Size.fromHeight(100);
@override
Widget build(BuildContext context) {
return Container(color: Colors.red);
}
}