popup showing in a flutter project at the opening of any app

36 Views Asked by At

I want to show some popups in a fluttter project to get location and disable battery optimazation whenever I open the app.

I tried and showed this popup using ElevatedButton. But as I want to show this popup at the opening of the app, so this work using elevated button is not appropriate for me. So, is it possible to show popup from the first second without using any elevated button or something else? If it is possiblem, then please guide me how to do this.

1

There are 1 best solutions below

0
il_boga On

In an app of mine, I show a privacy-related dialog this way:

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: [...],
        body: FutureBuilder(
              future: [...]
              builder: (context, snapshot) {
                  [..]
                      Future.delayed(Duration(milliseconds: 500), () {
                        showDialog(
                          context: context,
                          builder: (context) => AlertDialog(
                            scrollable: true,
                            title: Text('privacy'),
                            content: Text(Constants.LEGALESE),
                            actions: [...],
                          ),
                        );
                      });
                    }
                    [...rest of the build method...]
              })

You can adjust the Duration: in my case, it usually happens too fast for the user to do anything else.