'How to change floating action button between tabs in flutter

I am trying to implement different floating action button for different tabs in flutter. Upon entering a tab, the previous floating action button should hide and a new floating action button should appear (with animation). I have already implemented the method described in Flutter - Different floating action button in TabBar which works fine, but does not animate, and also delays in changing. So is there any better way to implement this desired behavior as shown below ?

Floating action button



Solution 1:[1]

You could use a tabController to get the index of the current tab. Then call setState to change the UI, eg setState(() => _myIndex = tabController.index )

Based on _myIndex display the button you want for the current tab.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dewaeq