flutterfloating-action-buttonflutter-pageview

Using Floating action button with PageView


I'm trying to use Flutter FAB in PageView, but since the FAB takes a variable that is initialized in the page 2, it creates an error.

So how can i show the FAB only after the second page?


Solution

  • The solution I used was to set a callback with the bool floating.

    on the home page:

    `

    bool floating = false;
    showFAB(show) {
        setState(() {
          floating = show;
        });
      }`
    

    floatingActionButton:(floating) ? FloatingMenu(pageController: pageController) : null,

    then on the initState function of second page used the callback to change the bool value