Cupertino 导航栏的问题

Issues with Cupertino Navigation Bar

我正在尝试创建自定义 CupertinoNavigationBar,但我不断收到与 ObstructingPreferredSizeWidget 相关的错误。有人可以告诉我我需要实施什么来解决这个问题吗?我收到的错误消息是:

Missing concrete implementation of 'ObstructingPreferredSizeWidget.shouldFullyObstruct'. Try implementing the missing method, or make the class abstract.

这是我的 CupertinoNavigationBar 的 class:

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,
    );
  }
}

如果您实施ObstructingPreferredSizeWidget,则必须实施以下方法:

  @override
  // TODO: implement preferredSize
  Size get preferredSize => throw UnimplementedError();

  @override
  bool shouldFullyObstruct(BuildContext context) {
    // TODO: implement shouldFullyObstruct
    throw UnimplementedError();
  }