2

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,
    );
  }
}
Washington Guedes
  • 4,254
  • 3
  • 30
  • 56

1 Answers1

3

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();
  }
0x4b50
  • 629
  • 6
  • 18