enable static method

Future<void> enable({
  1. required List<CNTab> tabs,
  2. int selectedIndex = 0,
  3. CNTabMinimizeBehavior minimizeBehavior = CNTabMinimizeBehavior.onScrollDown,
  4. CNTabAccessory? bottomAccessory,
  5. Color? tintColor,
  6. Color? unselectedTintColor,
  7. bool? isDark,
  8. bool asRoot = false,
  9. bool nativeSearchFilter = true,
  10. void onTabSelected(
    1. int index
    )?,
  11. void onListItemTap(
    1. int tabIndex,
    2. int itemIndex
    )?,
  12. void onSearchChanged(
    1. String query
    )?,
  13. VoidCallback? onAccessoryTap,
  14. VoidCallback? onDismissed,
  15. @Deprecated('No longer fired — use onSearchChanged. Will be removed in a future major release.') void onSearchSubmitted(
    1. String query
    )?,
  16. @Deprecated('No longer fired — use onSearchChanged. Will be removed in a future major release.') VoidCallback? onSearchCancelled,
  17. @Deprecated('No longer fired — use onSearchChanged. Will be removed in a future major release.') void onSearchActiveChanged(
    1. 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;
}