Как я могу отключить определенную вкладку в CupertinoTabView, чтобы иметь возможность нажимать?

#flutter #dart #flutter-cupertino

#flutter #dart #flutter-купертино

Вопрос:

Я хочу, чтобы, когда пользователь не вошел в систему, вкладки были отключены, за исключением вкладки «Mon Compte» и «Annonces» будут активированы. Есть ли способ отключить определенную вкладку в CupertinoTabView? чтобы ее нельзя было щелкнуть, если пользователь не вошел в систему? или как я могу изменить индекс, если пользователь не подключен, любая помощь приветствуется, спасибо!

 class BottomMenu extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _BottomMenuState();
  }
}

class _BottomMenuState extends State<BottomMenu> {
   static int currentTab = 3; // to keep track of active tab index


 @override
  Widget build(BuildContext context) {


    SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarBrightness: Brightness.light,
        systemNavigationBarColor: Colors.transparent,
        systemNavigationBarIconBrightness: Brightness.light,
      ),
    );

    return CupertinoTabScaffold(
      tabBar: CupertinoTabBar(
        currentIndex:  currentTab ,
        activeColor: Theme.of(context).primaryColor,
        backgroundColor: Theme.of(context).backgroundColor,
        inactiveColor: Theme.of(context).disabledColor,
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.search),
            title: Text(
                "Matching"
            ),
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.dashboard),
            title:
            Text(
                "Annonces"
            ),
          ),
          BottomNavigationBarItem(
            icon: Icon(MenuIcon.favorite__1_),
            title:
            Text("Favoris"),
          ),
          BottomNavigationBarItem(
            icon: Icon(MenuIcon.user__1_),
            title: Text(
                "Mon Compte"
            ),
          ),
        ],
      ),
      tabBuilder: (context, index) {
        switch (index) {

          case 0:
            return CupertinoTabView(builder: (context) {


                return CupertinoPageScaffold(
                  child: Matching(),
                );

            }

            );
          case 1:
            return CupertinoTabView(builder: (context) {

              return CupertinoPageScaffold(
                child: Offers(),
              );
            });
          case 2:
            return CupertinoTabView(builder: (context) {

              return CupertinoPageScaffold(
                child: Favorites(),
              );
            });
          default: return CupertinoTabView(

              builder: (context) {

            return CupertinoPageScaffold(
              child: Login(),
            );
          });
        }
      },
    );

  }
}