closeTab method

void closeTab(
  1. String route
)

Tab close karo. Agar active tab close ho raha hai → previous tab activate (ya null)

Implementation

void closeTab(String route) {
  final idx = _tabs.indexWhere((t) => t.route == route);
  if (idx == -1) return;

  _tabs.removeAt(idx);

  if (_activeRoute == route) {
    if (_tabs.isEmpty) {
      _activeRoute = null;
    } else {
      // Previous tab ko activate karo
      final newIdx = (idx - 1).clamp(0, _tabs.length - 1);
      _activeRoute = _tabs[newIdx].route;
    }
  }
  notifyListeners();
}