closeTab method

void closeTab(
  1. TabSwitcherTab tab
)

Implementation

void closeTab(TabSwitcherTab tab) {
  _tabs.remove(tab);

  var i = 0;
  for (var t in _tabs) {
    t._index = i++;
  }

  if (_currentTab == tab) {
    if (_tabs.isNotEmpty) {
      _currentTab = _tabs.last;
    } else {
      _currentTab = null;
      if (_switcherActive == false) {
        _switcherActive = true;
        _switchModeSubject.add(_switcherActive!);
      }
    }
    _currentTabChangedSubject.sink.add(_currentTab);
  }

  _tabClosedSubject.sink.add(tab);
}