fysoul17 / flutter_speed_dial_material_design

Flutter plugin to implement a Material Design Speed Dial (https://material.io/components/buttons-floating-action-button/#types-of-transitions)
MIT License
31 stars 9 forks source link

floatingActionButton remains visible after navigation to other routes/pages #5

Open teknolojia opened 4 years ago

teknolojia commented 4 years ago

Good work guys I like this lib but I faced this bug where floatingActionButton remains visible despite bottomBar being hidden in previous route.

here is the code.

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  SpeedDialController _controller = SpeedDialController();

  @override
  Widget build(BuildContext context) {

    return DefaultTabController(
        length: 4,
        child: Scaffold(
            body: CustomScrollView(
              slivers: <Widget>[
                SliverAppBar(
                  snap: false,
                  floating: false,
                  pinned: true,
                  expandedHeight: 160.0,
                ),
                SliverFillRemaining(
                  child: TabBarView(
                    children: <Widget>[
                      Activities(),
                    ],
                  ),
                )
              ],
            ),
            bottomNavigationBar: BottomAppBar(
              shape: CircularNotchedRectangle(),
              child: TabBar(
                tabs: <Widget>[
                ////OTHER TABS HERE
                  Tab(
                    //text: 'Activities',
                    icon: Icon(Icons.whatshot),
                  )
                ],
              ),
            ),
            floatingActionButtonLocation:
                FloatingActionButtonLocation.centerDocked,
            floatingActionButton: _buildFloatingActionButton()));
  }

  Widget _buildFloatingActionButton() {
    final TextStyle customStyle =
        TextStyle(inherit: false, color: Colors.black);
    final icons = [
      SpeedDialAction(
          child: Icon(Icons.send), label: Text('MENU 1', style: customStyle)),
      SpeedDialAction(
          child: Icon(Icons.arrow_downward),
          label: Text('MENU 2', style: customStyle)),
    ];

    return SpeedDialFloatingActionButton(
      actions: icons,
      childOnFold: Icon(Icons.menu, key: UniqueKey()),
      screenColor: Colors.black.withOpacity(0.3),
      childOnUnfold: Icon(Icons.close),
      useRotateAnimation: false,
      onAction: _onSpeedDialAction,
      controller: _controller,
      isDismissible: true,
      //backgroundColor: Colors.yellow,
      //foregroundColor: Colors.blue,
    );
  }

  _onSpeedDialAction(int selectedActionIndex) {
    if (selectedActionIndex == 0) {
      Navigator.push(
        context,
        MaterialPageRoute(builder: (context) => SelectContacts()),
      );
    }
  }
}

screenshots Screenshot_1592651182 Screenshot_1592651170 Screenshot_1592651182

Shiba-Kar commented 4 years ago

Facing the same Issue

unknownaloy commented 4 years ago

Is there a fix for this yet? I'm facing the same issue. A patch for this issue will be greatly appreciated.

guillermin commented 3 years ago

I am also facing this issue. I wrestled with it a bit last night to see if I could fix it but ended up deciding on using flutter_speed_dial instead.

If someone is interested in fixing this issue, here are some pointers:

If it were possible to register a routeObserver from within this package, or somehow read it without having to pass it down... On the other hand, perhaps using Overlay for this is just not the best way...