0

I have an app that has a ListView and Floating Button. I wanted to hide the Floating Button if Index 0 in the ListView is shown and show the Floating Button when Index 0 is not shown in the ListView. Most of the information in the web (including Stackoverflow) covers hiding the button when scrolling (direction) and not based on the index shown by ListView.

Calvin
  • 321
  • 2
  • 16
  • Does this answer your question? https://stackoverflow.com/questions/51069712/how-to-know-if-a-widget-is-visible-within-a-viewport – MSpeed Oct 26 '20 at 08:22

2 Answers2

0

you can checklist null or not. I just add a demo code.

List<String> demoList = new List<>();

floatingActionButton: demoList != null ?
 FloatingActionButton(
        onPressed: () {
          // Add your onPressed code here!
        },
        child: Icon(Icons.navigation),
        backgroundColor: Colors.green,
      )
:Text(''),
    );

if the list has a value then it shows a floating button.

0

Use Visibility widget around FloatingActionButton. When the item shows, just call setState() method with visibility value.

Mahi
  • 1,297
  • 1
  • 14
  • 28
  • Thanks for the feedbacks. I have found this widget and apparently it is requested to Flutter Team: https://github.com/flutter/flutter/issues/19941. In the thread, there is a solution proposed: https://pub.dev/packages/widgets_visibility_provider – Calvin Oct 26 '20 at 09:55