Reputation: 33
I'm trying to change the height of the CupertinoNavigationBar for my flutter app. I tried to do it with PreferredSize (like in material app) but unfortunately it doesn't work.
CupertinoPageScaffold(
navigationBar: PreferredSize(
preferredSize: Size.fromHeight(70.0),
child: CupertinoNavigationBar(),
),
child: Text('content'),
);
Error: The argument type 'PreferredSize' can't be assigned to the parameter type 'ObstructingPreferredSizeWidget?'
So, how can this be done for iOS?
Upvotes: 0
Views: 28
Reputation: 14775
As per CupertinoPageScaffold documenation you not declare PreferredSize
as navigationBar
, you can used CupertinoNavigationBar
as navigationBar
.
CupertinoPageScaffold
expects an ObstructingPreferredSizeWidget?
for its navigationBar
property, not a PreferredSize
. Remove the PreferredSize
You can directly use CupertinoNavigationBar
as the navigationBar
without wrapping it in PreferredSize
.
Refer below code:
MaterialApp(
debugShowCheckedModeBanner: false,
home: CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('Cupertino Page Scaffold Sample'),
),
child: Center(
child: Container(
child: Text('content'),
),
),
),
)
Upvotes: 0