user14892930
user14892930

Reputation: 63

Issues with Cupertino Navigation Bar

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

Answers (1)

0x4b50
0x4b50

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

Related Questions