FlutterChatAppTutorial icon indicating copy to clipboard operation
FlutterChatAppTutorial copied to clipboard

app bar

Open lkasumu opened this issue 3 years ago • 1 comments

when i call appBar: appBarMain(context) it gives me this error

The argument type 'Widget' can't be assigned to the parameter type 'PreferredSizeWidget?'.

how do I fix this, thank you

lkasumu avatar Feb 27 '22 18:02 lkasumu

Wrap a custom widget inside PreferredSize If you’re building a custom widget instead of AppBar, you need to wrap it:

PreferredSizeWidget appBarMain(BuildContext context) { return PreferredSize( preferredSize: const Size.fromHeight(60), // height of appbar child: Container( color: Colors.blue, alignment: Alignment.center, child: const Text( "Custom AppBar", style: TextStyle(color: Colors.white, fontSize: 20), ), ), ); }

UMMODI avatar Sep 02 '25 07:09 UMMODI