hacktons / convex_bottom_bar

A Flutter package which implements a ConvexAppBar to show a convex tab in the bottom bar. Theming supported.
https://bar.hacktons.cn
Apache License 2.0
801 stars 151 forks source link

Highlighted Icon Incorrect - Back Navigation #112

Closed JayDev43 closed 4 years ago

JayDev43 commented 4 years ago

Describe the bug

When navigating back from another page to a page containing the ConvexBottomBar where the initialActiveIndex value is set and the index when I navigated away from the page is not equal to the initialActiveIndex then the highlighted icon is incorrect. The page highlights the icon of the initialActiveIndex rather than the index I was on when I navigated away. See screenshot below.

Code for setting up the ConvexAppBar is below.

bottomNavigationBar: ConvexAppBar(
        style: TabStyle.react,
        color: Theme.of(context).primaryColor,
        activeColor: Theme.of(context).primaryColor,
        backgroundColor: Theme.of(context).bottomAppBarColor,
        items: const [
          TabItem(icon: Icons.list),
          TabItem(icon: Icons.calendar_today),
          TabItem(icon: Icons.assessment),
        ],
        initialActiveIndex: 1,
        onTap: (int i) => print('click index=$i'),
      ),

Environment details

Paste the flutter environment detail.

Flutter 1.22.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision d408d302e2 (11 days ago) • 2020-09-29 11:49:17 -0700
Engine • revision 5babba6c4d
Tools • Dart 2.10.0

Paste the package version.

dependencies:
  convex_bottom_bar: ^2.5.1+1

To Reproduce

Steps to reproduce the behavior:

  1. Go to Page using ConvexBottomAppBar
  2. Change away from initial index
  3. Navigate to new page
  4. Use back button (Hardware or Software button)
  5. The result is the convex line being over the index I was on when I navigated away, but the highlighted icon is based on the initial index

Expected behavior

I expected both the convex line and the highlighted icon to be on the same index in the app bar and I expected this index to be whichever I was on prior to navigating away from the page.

Screenshots

Screenshot added of what it looks like once the I navigate back to page

Screenshot_1602343380

avenwu commented 4 years ago

@JayDev43 This bug has been fixed.

dependencies:
  convex_bottom_bar:
    git:
      url: https://github.com/hacktons/convex_bottom_bar.git
      ref: patch-highlight
najafsikander commented 4 years ago

Same error occur when keyboard opens and then closes

avenwu commented 4 years ago

any detail log?

najafsikander commented 4 years ago

It doesn't give any logs in console. It just happens. Fixed it by your solution

@JayDev43 This bug has been fixed.

dependencies:
  convex_bottom_bar:
    git:
      url: https://github.com/hacktons/convex_bottom_bar.git
      ref: patch-highlight
avenwu commented 4 years ago

👌

avenwu commented 4 years ago

@najafsikander v2.6.0 has been shipped. You may switch to update the version now. Feel free to fire a issue if the package brother you😅