Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Multiple dialogs on multiple Routes #75

Open
richardkrieger opened this issue Aug 2, 2020 · 0 comments
Open

Multiple dialogs on multiple Routes #75

richardkrieger opened this issue Aug 2, 2020 · 0 comments

Comments

@richardkrieger
Copy link

Working example for problem:

    import 'package:flutter/material.dart';
    import 'package:progress_dialog/progress_dialog.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
    
        @override
        Widget build(BuildContext context) {
            return MaterialApp(
                    title: 'Flutter Demo',
                    theme: ThemeData(
                        primarySwatch: Colors.blue,
                    ),
                    home: ParentWidget()
            );
        }
    }
    
    class ParentWidget extends StatelessWidget {
        @override
        Widget build(BuildContext context) {
            return Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                    Text("PatentWidget"),
                    RaisedButton(
                        child: Text("start child 1"),
                        onPressed: () async{
                            ProgressDialog progressDialog = ProgressDialog(
                                context,
                                type: ProgressDialogType.Normal,
                                isDismissible: true,
                            );
                            progressDialog.show();
                            await new Future.delayed(const Duration(seconds : 1)); // simulate loading
                await Navigator.push(
                    context, MaterialPageRoute <dynamic>(
                        builder: (context) => Child1Widget()
                  )
                );
                progressDialog.hide();
              }
                    ),
    
                ],
            );
        }
    }
    
    class Child1Widget extends StatelessWidget {
        @override
        Widget build(BuildContext context) {
            return Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                    Text("Child1Widget"),
                    RaisedButton(
                        child: Text("start child 2"),
                        onPressed: () async{
                            ProgressDialog progressDialog = ProgressDialog(
                                context,
                                type: ProgressDialogType.Normal,
                                isDismissible: true,
                            );
                            progressDialog.show();
                            await new Future.delayed(const Duration(seconds : 1)); // simulate loading
                            await Navigator.push(
                                    context, MaterialPageRoute <dynamic>(
                                        builder: (context) => Child2Widget()
                                )
                            );
                            progressDialog.hide();
                        },
                    ),
                    RaisedButton(
                            child: Text("back to parent"),
                            onPressed: () {
                                Navigator.of(context).pop();
                            }
                    )
                ],
            );
        }
    }
    
    class Child2Widget extends StatelessWidget {
        @override
        Widget build(BuildContext context) {
            return Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                    Text("Child2Widget"),
                    RaisedButton(
                            child: Text("back to child 1"),
                            onPressed: () {
                                Navigator.of(context).pop();
                            }
                    )
                ],
            );
        }
    }

ParentWidget -> Child1Widget and back works properly

ParentWidget -> Child1Widget -> Child2Widget:

  1. Child1Widget -> Child2Widget - no dialog
  2. Child2Widget -> Child1Widget -> ParentWidget - dialog on ParentWidget cannot be removed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant