Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kzrnm opened this issue Mar 27, 2024 · 3 comments

Comments

@kzrnm
Copy link

kzrnm commented Mar 27, 2024

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
Copy link

HSCOGT commented Mar 28, 2024

+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
Copy link

mdavo6 commented Jul 2, 2024

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:

#### How to use `openCloseDial` property:

Hope that helps someone!

@Alvish0407
Copy link

You can use RouteAware mixin on MyHomePage. It contains didPush(), didPushNext(), didPopNext() methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants