buildByCupertino method

  1. @override
Widget buildByCupertino(
  1. BuildContext context
)

*** native iOS properties end ***

Implementation

@override
Widget buildByCupertino(BuildContext context) {
  final Widget? _leading = valueOf('leading', leading);
  // If trailing is null and actions is not null, with length > 1, set trailing = actions[0];
  Widget? _trailing = valueOf('trailing', trailing);
  final List<Widget>? _actions = valueOf('actions', actions);
  if (_actions != null && _actions.isNotEmpty && _trailing == null) {
    if (actions!.length == 1) {
      _trailing = _actions[0];
    } else {
      _trailing = Row(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.end,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: _actions,
      );
    }
  }
  final BaseThemeData baseTheme = BaseTheme.of(context);
  final Widget? _title = valueOf('middle', middle) ?? valueOf('title', title);
  // If no backgroundColor, use CupertinoTheme's barBackgroundColor, or use the default
  final Color? _backgroundColor = valueOf('backgroundColor', backgroundColor);
  final double _toolbarOpacity = valueOf('toolbarOpacity', toolbarOpacity);

  // Enhanced backdrop filter logic
  bool _backdropFilter = valueOf('backdropFilter', backdropFilter) ??
      baseTheme.valueOf(
        'appBarBackdropFilter',
        baseTheme.appBarBackdropFilter,
      ) ??
      true;
  // No blur when background color is opaque
  if (_backgroundColor?.alpha == 0xFF) {
    _backdropFilter = false;
  }

  CupertinoNavigationBar cupertinoNavigationBar;
  final double? _height = valueOf('height', height) ??
      baseTheme.valueOf('appBarHeight', baseTheme.appBarHeight);
  final bool? _transitionBetweenRoutes =
      valueOf('transitionBetweenRoutes', transitionBetweenRoutes) ??
          baseTheme.appBarTransitionBetweenRoutes;
  final Object? _heroTag = valueOf('heroTag', heroTag);

  if (_heroTag != null) {
    cupertinoNavigationBar = CupertinoNavigationBar(
      leading: _leading,
      automaticallyImplyLeading: valueOf(
        'automaticallyImplyLeading',
        automaticallyImplyLeading,
      ),
      automaticallyImplyMiddle: automaticallyImplyMiddle,
      previousPageTitle: previousPageTitle,
      middle: _title,
      trailing: _trailing,
      border: valueOf('border', border),
      backgroundColor: _backgroundColor,
      brightness: valueOf('brightness', brightness),
      padding: valueOf('padding', padding),
      transitionBetweenRoutes: _transitionBetweenRoutes!,
      heroTag: _heroTag,
      backdropFilter: _backdropFilter,
      navBarPersistentHeight: _height,
      bottom: valueOf('bottom', bottom),
      bottomOpacity: valueOf('bottomOpacity', bottomOpacity),
      toolbarOpacity: _toolbarOpacity,
    );
  } else {
    cupertinoNavigationBar = CupertinoNavigationBar(
      key: valueOf('key', key),
      leading: _leading,
      automaticallyImplyLeading: valueOf(
        'automaticallyImplyLeading',
        automaticallyImplyLeading,
      ),
      automaticallyImplyMiddle: automaticallyImplyMiddle,
      previousPageTitle: previousPageTitle,
      middle: _title,
      trailing: _trailing,
      border: valueOf('border', border),
      backgroundColor: _backgroundColor,
      brightness: valueOf('brightness', brightness),
      padding: valueOf('padding', padding),
      transitionBetweenRoutes: _transitionBetweenRoutes!,
      backdropFilter: _backdropFilter,
      navBarPersistentHeight: _height,
      bottom: valueOf('bottom', bottom),
      bottomOpacity: valueOf('bottomOpacity', bottomOpacity),
      toolbarOpacity: _toolbarOpacity,
    );
  }

  return cupertinoNavigationBar;
}