enable static method
Future<void>
enable({
- required List<
CNTab> tabs, - int selectedIndex = 0,
- CNTabMinimizeBehavior minimizeBehavior = CNTabMinimizeBehavior.onScrollDown,
- CNTabAccessory? bottomAccessory,
- Color? tintColor,
- Color? unselectedTintColor,
- bool? isDark,
- bool asRoot = false,
- bool nativeSearchFilter = true,
- void onTabSelected(
- int index
- void onListItemTap()?,
- void onSearchChanged(
- String query
- VoidCallback? onAccessoryTap,
- VoidCallback? onDismissed,
- @Deprecated('No longer fired — use onSearchChanged. Will be removed in a future major release.') void onSearchSubmitted(
- String query
- @Deprecated('No longer fired — use onSearchChanged. Will be removed in a future major release.') VoidCallback? onSearchCancelled,
- @Deprecated('No longer fired — use onSearchChanged. Will be removed in a future major release.') void onSearchActiveChanged(
- bool isActive
Present the native tab bar configured from tabs.
Implementation
static Future<void> enable({
required List<CNTab> tabs,
int selectedIndex = 0,
CNTabMinimizeBehavior minimizeBehavior = CNTabMinimizeBehavior.onScrollDown,
CNTabAccessory? bottomAccessory,
Color? tintColor,
Color? unselectedTintColor,
bool? isDark,
bool asRoot = false,
bool nativeSearchFilter = true,
void Function(int index)? onTabSelected,
void Function(int tabIndex, int itemIndex)? onListItemTap,
void Function(String query)? onSearchChanged,
VoidCallback? onAccessoryTap,
VoidCallback? onDismissed,
@Deprecated(
'No longer fired — use onSearchChanged. Will be removed in a future major release.',
)
void Function(String query)? onSearchSubmitted,
@Deprecated(
'No longer fired — use onSearchChanged. Will be removed in a future major release.',
)
VoidCallback? onSearchCancelled,
@Deprecated(
'No longer fired — use onSearchChanged. Will be removed in a future major release.',
)
void Function(bool isActive)? onSearchActiveChanged,
}) async {
// iOS 26+ only — no-op elsewhere.
if (defaultTargetPlatform != TargetPlatform.iOS ||
!PlatformVersion.shouldUseNativeGlass) {
return;
}
if (_enabled) return;
_onTabSelected = onTabSelected;
_onListItemTap = onListItemTap;
_onSearchChanged = onSearchChanged;
_onAccessoryTap = onAccessoryTap;
_onDismissed = onDismissed;
_channel.setMethodCallHandler(_handle);
await _channel.invokeMethod('enable', {
'tabs': [
for (final t in tabs)
{
'title': t.title,
'sfSymbol': t.sfSymbol?.name,
'isSearch': t.isSearchTab,
'badgeCount': t.badgeCount,
if (t.nativeList != null)
'nativeList': {
'items': [for (final i in t.nativeList!.items) _itemMap(i)],
},
},
],
'selectedIndex': selectedIndex,
'minimizeBehavior': minimizeBehavior.name,
if (bottomAccessory != null)
'bottomAccessory': _accessoryMap(bottomAccessory),
if (tintColor != null) 'tint': tintColor.toARGB32(),
if (unselectedTintColor != null)
'unselectedTint': unselectedTintColor.toARGB32(),
'isDark': isDark ?? false,
'asRoot': asRoot,
'nativeSearchFilter': nativeSearchFilter,
});
_enabled = true;
}