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

FAB position validation still throws exception with centered position #87

Open
zeeshanahmad0201 opened this issue Nov 20, 2024 · 0 comments · May be fixed by #88
Open

FAB position validation still throws exception with centered position #87

zeeshanahmad0201 opened this issue Nov 20, 2024 · 0 comments · May be fixed by #88

Comments

@zeeshanahmad0201
Copy link

zeeshanahmad0201 commented Nov 20, 2024

Despite the previous fix in #23 , the position validation is still causing issues with centered FABs. The current validation uses exact position comparison which is too strict for real-world scenarios.

Current behavior:

  • Throws exception: "Wrong gap location in AnimatedBottomNavigationBar towards FloatingActionButtonLocation => consider use GapLocation.end instead of GapLocation.center"
  • Even when FAB and gap location are both set to center

Expected behavior:

  • Should work when FAB and gap locations are properly aligned
  • Should handle slight position variations due to floating-point precision

Proposed solution:

  • Implement threshold-based position validation
  • Use percentage-based tolerance (10% of width)
  • Replace integer comparisons with float comparisons

Example code showing the issue:

Scaffold(
  bottomNavigationBar: AnimatedBottomNavigationBar.builder(
      shadow: Shadow(
        color: context.colorScheme.secondary.withOpacity(0.25),
        blurRadius: 20.r,
      ),
      height: max(kBottomNavigationBarHeight, Dimens.navBarHeight),
      itemCount: BottomNavItem.values.length,
      tabBuilder: (int index, bool isActive) =>
          _buildNavItem(context, BottomNavItem.values[index], isActive),
      scaleFactor: 0.5,
      activeIndex: currentItem.index,
      onTap: (index) => context
          .read<BottomNavCubit>()
          .updateItem(BottomNavItem.values[index]),
      gapLocation: GapLocation.center,
      notchSmoothness: NotchSmoothness.softEdge,
    ),
  floatingActionButton: FloatingActionButton(...),
  floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant