newTab method
Open a new tab with page
as the body.
Implementation
@action
void newTab({
Widget? page,
String tabId = '',
TabPosition position = TabPosition.after,
}) {
final index =
tabId.isNotEmpty ? tabs.indexWhere((e) => e.id == tabId) : selectedTab;
selectedTab = index == -1
? (position == TabPosition.after ? tabs.length + 1 : 0)
: index + (position == TabPosition.after ? 1 : 0);
// Make sure the value is in the proper range
selectedTab = max(0, min(selectedTab, tabs.length));
tabs.insert(
selectedTab,
Tab(
panel: this as TabPanel,
pages: [page ?? defaultPage].asObservable(),
),
);
}