buildByCupertinoNative method
build on cupertino mode with native iOS components (cupertino_native package) This is called when baseParam.nativeIOS = true Default implementation falls back to buildByCupertino()
Implementation
@override
Widget buildByCupertinoNative(BuildContext context) {
// Native iOS implementation using BaseNavigationBar which handles CNNavigationBar internally
// Liquid Glass effects are not applicable here as CNNavigationBar handles its own native rendering
final Widget? _titleWidget =
valueOf('middle', middle) ?? valueOf('title', title);
// Extract title text if it's a Text widget
String? _title;
if (_titleWidget is Text) {
_title = _titleWidget.data ?? _titleWidget.textSpan?.toPlainText();
}
// Use the dedicated leadingActions and trailingActions properties
final List<BaseNavigationBarAction>? _leadingActions =
valueOf('leadingActions', leadingActions);
final List<BaseNavigationBarAction>? _trailingActions =
valueOf('trailingActions', trailingActions);
final Color? _tint = valueOf('tint', tint);
final double? _height = valueOf('height', height);
final bool _transparent = valueOf('transparent', transparent);
final bool _largeTitle = valueOf('largeTitle', largeTitle);
final BaseThemeData baseTheme = BaseTheme.of(context);
final double effectiveHeight = _height ??
baseTheme.valueOf('appBarHeight', baseTheme.appBarHeight) ??
44.0;
// BaseNavigationBar.build() returns CNNavigationBar which doesn't implement PreferredSizeWidget
// Wrap it in PreferredSize to make it compatible with ObstructingPreferredSizeWidget
final Widget navBar = SafeArea(
child: BaseNavigationBar(
key: valueOf(
'key', key), // Pass through the key for proper rebuild behavior
leading: _leadingActions,
title: _title,
trailing: _trailingActions,
tint: _tint,
transparent: _transparent,
largeTitle: _largeTitle,
height: _height,
segmentedControlLabels:
valueOf('segmentedControlLabels', segmentedControlLabels),
segmentedControlSelectedIndex: valueOf(
'segmentedControlSelectedIndex', segmentedControlSelectedIndex),
onSegmentedControlValueChanged: valueOf(
'onSegmentedControlValueChanged', onSegmentedControlValueChanged),
segmentedControlHeight:
valueOf('segmentedControlHeight', segmentedControlHeight),
segmentedControlTint:
valueOf('segmentedControlTint', segmentedControlTint),
segmentedControlLabelSize:
valueOf('segmentedControlLabelSize', segmentedControlLabelSize),
baseParam: BaseParam(nativeIOS: true),
).build(context),
);
return PreferredSize(
preferredSize: Size.fromHeight(effectiveHeight),
child: navBar,
);
}