Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change the currentIndex using Global Key #203

Open
direct2harsh opened this issue Sep 25, 2023 · 1 comment
Open

Cannot change the currentIndex using Global Key #203

direct2harsh opened this issue Sep 25, 2023 · 1 comment

Comments

@direct2harsh
Copy link

direct2harsh commented Sep 25, 2023

Hi,
I need to change index (navigate to another page using Page Controller) by click on a TextButton.
I am able to switch to another page but the Convex_bottom_bar does not change the UI for the current page like the active Tab text and Convex radius. It stays the same as default index of 0.

I created a Global key and used it like -
final ConvexAppBar navigationBar = bottomNAVKey.currentWidget;
navigationBar.onTap(1);

Any help is appreciated.

@Milan-Verselix
Copy link

Milan-Verselix commented Sep 26, 2023

I have same issue with this plugin...

Please tell me How can I Change convex appbar current index programatically ?

My Convex Widget :

bottomNavigationBar: ConvexAppBar.builder(
        itemBuilder: Builder(),
        count: 5,
        height: 61,
        backgroundColor: AppColors.mainBlueColor,
        onTap: (int i) {
          controller.selectPage(i);
        },
      ),

Item Builder :

class Builder extends DelegateBuilder {
  var icons=[[Images.icHome,"Home"],[Images.icHistory,"History"],[Images.avtar,"Profile"],[Images.icGame,"Game"],[Images.icReward,"Reward"],];
  @override
  Widget build(
    BuildContext context,
    int index,
    bool active,
  ) {
    if (index == 2) {
      return Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          SizedBox(
            height: 10,
          ),
          Container(
              height: active ? 45 : 36,
              width: active ? 45 : 36,
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                color: active ? Colors.white : AppColors.darkBlueColor,
              ),
              padding: EdgeInsets.all(2),
              child: CircleAvatar(
                backgroundImage: AssetImage(Images.avtar),
              )),
          SizedBox(
            height: active ? 4 : 1,
          ),
          Text(
            "Profile",
            style: TextStyle(
                fontFamily: Fonts.albertsans,
                fontSize: 12,
                color: active ? Colors.white : AppColors.darkBlueColor),
          ),
        ],
      );
    }
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        SizedBox(
          height: 10,
        ),
        SvgPicture.asset(
          icons[index][0],
          height: active ? 34 : 30,
          width: active ? 34 : 30,
          color: active ? Colors.white : AppColors.darkBlueColor,
        ),
        SizedBox(
          height: 5,
        ),
        Text(
          icons[index][1],
          style: TextStyle(
            fontFamily: Fonts.albertsans,
            fontSize: 12,
            color: active ? Colors.white : AppColors.darkBlueColor,
          ),
        ),
        SizedBox(
          height: 2,
        ),
      ],
    );
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants