flutter_speed_dial icon indicating copy to clipboard operation
flutter_speed_dial copied to clipboard

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

Open kzrnm opened this issue 1 year ago • 3 comments

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"),
          ),
        ),
      ),
    );
  }
}

kzrnm avatar Mar 27 '24 17:03 kzrnm

+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).

HSCOGT avatar Mar 28 '24 00:03 HSCOGT

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!

mdavo6 avatar Jul 02 '24 23:07 mdavo6

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

Alvish0407 avatar Aug 20 '24 10:08 Alvish0407