Reputation: 63
I am trying to create a custom CupertinoNavigationBar but I keep getting errors related to ObstructingPreferredSizeWidget. Can someone tell me what I need to implement to fix this? The error message I am getting is:
Missing concrete implementation of 'ObstructingPreferredSizeWidget.shouldFullyObstruct'. Try implementing the missing method, or make the class abstract.
Here is the class for my CupertinoNavigationBar:
class CupertinoTopBar extends StatelessWidget
implements ObstructingPreferredSizeWidget {
Size preferredSize = Size.fromHeight(kToolbarHeight);
@override
Widget build(BuildContext context) {
return CupertinoNavigationBar(
leading: Text('AUC_CS'),
backgroundColor: CupertinoTheme.of(context).primaryColor,
);
}
}
Upvotes: 2
Views: 716
Reputation: 679
If you implement ObstructingPreferredSizeWidget
you have to implement the following methods:
@override
// TODO: implement preferredSize
Size get preferredSize => throw UnimplementedError();
@override
bool shouldFullyObstruct(BuildContext context) {
// TODO: implement shouldFullyObstruct
throw UnimplementedError();
}
Upvotes: 4