enable static method
Future<void>
enable({
- required List<
CNTab> tabs, - int selectedIndex = 0,
- void onTabSelected(
- int index
- void onSearchChanged(
- String query
- void onSearchSubmitted(
- String query
- VoidCallback? onSearchCancelled,
- void onSearchActiveChanged(
- bool isActive
- Color? tintColor,
- Color? unselectedTintColor,
- bool? isDark,
Enable native tab bar mode
This will replace your app's root view controller with a native UITabBarController. Your Flutter content will be displayed within the selected tab.
Only works on iOS 26+. On older versions, this is a no-op.
Implementation
static Future<void> enable({
required List<CNTab> tabs,
int selectedIndex = 0,
void Function(int index)? onTabSelected,
void Function(String query)? onSearchChanged,
void Function(String query)? onSearchSubmitted,
VoidCallback? onSearchCancelled,
void Function(bool isActive)? onSearchActiveChanged,
Color? tintColor,
Color? unselectedTintColor,
bool? isDark,
}) async {
// Only works on iOS 26+
if (defaultTargetPlatform != TargetPlatform.iOS ||
!PlatformVersion.shouldUseNativeGlass) {
return;
}
if (_isEnabled) {
return;
}
// Store callbacks
_onTabSelected = onTabSelected;
_onSearchChanged = onSearchChanged;
_onSearchSubmitted = onSearchSubmitted;
_onSearchCancelled = onSearchCancelled;
_onSearchActiveChanged = onSearchActiveChanged;
// Setup method call handler for callbacks
_channel.setMethodCallHandler(_handleMethodCall);
// Enable native tab bar
await _channel.invokeMethod('enable', {
'tabs': tabs
.map(
(tab) => {
'title': tab.title,
'sfSymbol': tab.sfSymbol?.name,
'activeSfSymbol': tab.activeSfSymbol?.name,
'isSearch': tab.isSearchTab,
'badgeCount': tab.badgeCount,
},
)
.toList(),
'selectedIndex': selectedIndex,
'isDark': isDark ?? false,
if (tintColor != null) 'tint': tintColor.toARGB32(),
if (unselectedTintColor != null)
'unselectedTint': unselectedTintColor.toARGB32(),
});
_isEnabled = true;
}