zuvola / flutter_expandable_fab

MIT License
23 stars 28 forks source link

Animation glitch when mixing FloatingActionButton and ExpandableFab #33

Open aloh86 opened 1 month ago

aloh86 commented 1 month ago

I have a Scaffold in which I mix FloatingActionButton and ExpandableFab depending on the screen shown. When I render the screen (through bottom navigation bar switch) that has the ExpandableFab, I see the button moving into position to the bottom right. I'm also setting location based on the screen where I show the ExpandableFab:

Scaffold(
    ...
    floatingActionButton: _getFloatingActionButton(_bottomNavCurrentIndex),
    floatingActionButtonLocation: _getLocation(_bottomNavCurrentIndex),
    ...
)

FloatingActionButtonLocation? _getLocation(int bottomNavCurrentIndex) {
    if (_navItems.length == 4 && _bottomNavCurrentIndex == 2 || _navItems.length == 5 && _bottomNavCurrentIndex == 3) {
      return ExpandableFab.location;
    }

    // Floating action button's default position
    return null;
}

You can see (from the video) that if I go from a screen where ExpandableFab is showing to a screen with a FloatingActionButton, you can momentarily see the FAB in the top left, and then suddenly appear bottom right where it should be. If you go from a screen with FloatingActionButton to a screen with an ExpandableFab, you see the ExpandableFab animate a little offset from where it should be to its final position.

Is there a way to make these two work together?

Screen_recording_20241017_155853.webm

dimabran commented 2 days ago

I have the same issue, and i fixed it by defining the key outside the build method of the widget.