darioielardi / flutter_speed_dial

Flutter plugin to implement a Material Design Speed Dial
https://pub.dev/packages/flutter_speed_dial
MIT License
410 stars 177 forks source link

Overlay remains if Navigator.push is called immediately after opening SpeedDial #327

Open kzrnm opened 3 months ago

kzrnm commented 3 months ago

Run the code below. If the Next page button is pressed immediately after opening SpeedDial, it becomes uncontrollable.

image

Example

import 'package:flutter/material.dart';
import 'package:flutter_speed_dial/flutter_speed_dial.dart';

void main() =>
    runApp(const MaterialApp(title: "Speed Dial", home: MyHomePage()));

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Speed Dial")),
      backgroundColor: Colors.black,
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            Navigator.of(context).push(
              MaterialPageRoute(builder: (context) => const NextPage()),
            );
          },
          child: const Text('Next page'),
        ),
      ),
      floatingActionButton: SpeedDial(
        children: [
          SpeedDialChild(
            child: const Icon(Icons.accessibility),
            backgroundColor: Colors.red,
          ),
        ],
      ),
    );
  }
}

class NextPage extends StatelessWidget {
  const NextPage({super.key});

  @override
  Widget build(BuildContext context) {
    return PopScope(
      canPop: false,
      child: Scaffold(
        backgroundColor: Colors.black,
        body: Center(
          child: ElevatedButton(
            onPressed: () => Navigator.pop(context),
            child: const Text("back"),
          ),
        ),
      ),
    );
  }
}
HSCOGT commented 3 months ago

+1 Similar case, I'm not navigating after but the overlay persists after an option is selected. Weirdly enough it only happens on a physical device, everything works fine on the emulator (iOS).

mdavo6 commented 6 days ago

I had a similar situation. Was able to resolve by using the OpenCloseDial property, and adding the following line to close the speed dial prior to navigating to another page: isDialOpen.value = false;

See more info: https://github.com/darioielardi/flutter_speed_dial/blob/6608449829223c95752c93c8cabbc40730ebd72b/README.md?plain=1#L88

Hope that helps someone!