flutter show dialog on start

  BuildContext dialogContext; // <<----
  showDialog(
    context: context, // <<----
    barrierDismissible: false,
    builder: (BuildContext context) {
      dialogContext = context;
      return Dialog(
        child: new Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            new CircularProgressIndicator(),
            new Text("Loading"),
          ],
        ),
      );
    },
  );

  await _longOperation();
  Navigator.pop(dialogContext); // <<----

4.3
10
Ash82910 95 points

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

  void main() {
    runApp(new MyApp());
  }

  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
          title: 'Trial',
          home: Scaffold(
              appBar: AppBar(title: Text('List scroll')), body: new MyHome()));
    }
  }

  class MyHome extends StatelessWidget { // Wrapper Widget
    @override
    Widget build(BuildContext context) {
      Future.delayed(Duration.zero, () =&gt; showAlert(context));
      return Container(
        child: Text(&quot;Hello world&quot;),
      );
    }

    void showAlert(BuildContext context) {
      showDialog(
          context: context,
          builder: (context) =&gt; AlertDialog(
                content: Text(&quot;hi&quot;),
              ));
    }
  }

4.3 (10 Votes)
0
3.57
7
Ken Y-N 110 points

                                    
class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() =&gt; _MyHomePageState();
}

class _MyHomePageState extends State&lt;MyHomePage&gt; {
  int _counter = 0;

  void initState(){
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback(
            (_) =&gt; _showStartDialog()
    );
  }
  
  Future&lt;void&gt; _showStartDialog() async {
    return showDialog&lt;void&gt;(
      context: context,
      barrierDismissible: false, // user must tap button!
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('AlertDialog Title'),
          content: SingleChildScrollView(
            child: ListBody(
              children: &lt;Widget&gt;[
                Text('This is a demo alert dialog.'),
                Text('Would you like to approve of this message?'),
              ],
            ),
          ),
          actions: &lt;Widget&gt;[
            TextButton(
              child: Text('Approve'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }
  
  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: &lt;Widget&gt;[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

3.57 (7 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
show dialog to update when the app start in flutter flutter dialog return show a dialog when opening the app flutter flutter dialog dismissible flutter dialog dismissable how to close dialog from outside flutter flutter dialog popup time call dialog from ouside flutter flutter show dialog on start application is that possible that i can show dialog on start application flutter flutter show dialog on start apliction show button show dialog flutter show dialog on widget flutter pop showDialog flutter automatically flutter finished dialog flutter dialog with result flutter dismissible dialog flutter alert dialog close button close all show dialog flutter flutter close all dialogs flutter dialog dismiss duration dismiss Dialog outside dialog widget flutter alert dialof close Button Flutter how to close a dialog in flutter flutter showDialog navigator pop dismisses view below flutter show dialog box dismiss a dialog flutter dialog exit to app in flutter flutter 2 close dialog button showdialog flutter open another showDialog and close it call widget build from show dialog alert dialog flutter flutter button to close dialog dialog show flutter Dialog flutter show an close flutter close dialog setstate flutter show dialog actions How to call a Dialog box automatically in flutter alert dialog flutter without click close flutter how to close showDialog close alert dialog on pressed flutter function to close alert dialog in flutter alert dialog close button flutter exit dialog in flutter without pop show app inside dialog flutter flutter close dialog from outside flutter showdialog close flutter show dialog when build showdialog not dismiss flutter show a dialog in flutter show dialog on button pressed flutter flutter close dialog only close dialob box flutter flutter do something when dialog opens Flutter close popup dialog how to dismiss a dialog from the viewmodel in flutter return data after close dialog flutter show dialog flutter from the right close a dialog flutter close dialog when click outside flutter flutter show dialog close flutter show dialog after build show dialog on button click flutter how to show dialog in flutter Flutter dismiss dialog from outside show dialog for ios flutter dialog window flutter flutter showDialog actopms showGeneralDialog click to close in flutter detect dialog dismiss flutter show dialog at statup flutter flutter Close about dialogue flutter close alertdialog flutter programmatical close dialog launch dialog on page launch flutter flutter simple dialog close button dialog box dont close flutter how to close a dialogbox flutter simpledialog close using button flutter flutter button open dialog window dismiss dialog box flutter function return show dialog flutter show dialog from specific widget flutter flutter close show dialog flutter show dialog on pressed menu flutter show dialog on click menu flutter show simple dialog show dialog before pop in flutter dialog box before exiting APP in flutter dialog box before exiting in flutter alert dialog box before exiting in flutter flutter close dialog box and open new screen show dialog showing only once flutter open dialog from button flutter how to close dialog in flutter flutter make dialog go away show dialog box in flutter with actions flutter dismiss general dialog simpledialog wont open in flutter close a flutter alert dialog flutter show a dialog oninit flutter close dialog programmatically how to close a showdialog from another function in flutter simpledialog flutter close how to close alert dialog in flutter on click start action after dialog will pop up in flutter flutter how to show dialog flutter show dialog on start how to close showdialog in flutter flutter dialog with options flutter show dialog before build on pressed close dialog flutter close simpledialog flutter how to show dialog in app startup flutter flutter onpressed show dialog flutter cupertinoalertdialog close dialog show dialog in flutter flutter showDialog with position close button on op right flutter open dialog show dialog initStatein flutter pass showdialog close data flutter pass show dialog close data flutter flutter open dialog from function alertdialog cannot close flutter close alert dialog flutter close alertdialog flutter how to open and close showDialog in flutter flutter alertdialog with close button flutter show dialog after pop how to close out alert dialog in flutter flutter show dialog then show dialog over apps on button click flutter showing dialog in flutter flutter dismiss showdialog close dialog in getx flutter flutter dialog box with close button flutter get dialog dismiss &quot;Get.dialog&quot; flutter get dialog close flutter check when dialog closes flutter close dialog box flutter get dialog hide flutter show dialog without dialog flutter get dialog open flutter exit app dialog box close dialog in flutter not dismissable Ok button close dialog flutter how to close a dialog box flutter flutter dialog on dismiss keep dialog open in flutter by default flutter showdialog close event show dialog in return flutter flutter simpledialog close flutter show dialog on widget load flutter dialog window how to put a dialog check when app starts flutter flutter open dialog once on will pop flutter dialog flutter closing dialog manualy flutter show a dialog dialog when app start flutter show dialog flutter do not close on click flutter close dialogbox on click flutter close dialog on button press showdialog move flutter position flutter dialog dismiss screen flutter dialog dismiss widget flutter dialog not dismissing how to call a dialog from scaffold flutter close alert dialog in flutter show general dialog flutter dismiss all dialog flutter showdialog cancel 'showdialog' widget exit dialog flutter show dialog after post method in flutter how to close a dialog flutter dismass dialoge flutter AlertDialog detect close flutter show Dialog flutter is dissmisable flutter do something when dialog close flutter show dialog on app start show dialog on dismiss flutter showDialog inside widget flutter showDialog in side widget flutter is showdialog a widget in flutter how to know when user dismisses modal popup flutter flutter material app showdialog AlertDialog button close flutter flutter close alert dialog showDialog on cancel flutter flutter showdialog example flutter showdialog without close flutter on popup close flutter getx close dialog flutter get value from dialog on close how to dismiss a dialog in flutter how to make alert dialog from bottom of mobile in flutter how to show a dialog flutter flutter open modal flutter show dialog example dialog to navigation flutter showdialog flutter example flutter on page close call showdialog inside showdialog function futter how to close an alert box flutter close showdialog button flutter flutter modal dialog flutter + showDialog flutter dialog close button make flutter dialognon dismissible showdialog dismiss flutter close dialog box flutter show dialog box in flutter Close show dialog flutter flutter prevent close dialog flutter EasyDialog close manually dialogue close flutter how to dismiss dialog in flutter showdialog flutter dismiss showDialog close flutter how to close alert dialog in flutter flutter show dialog program close dialog flutter flutter dialog close event flutter dialog on close close app from dialog flutter dialog box close in flutter flutter show dialogh gext close dialog flutter showdialog flutter context showdialog async flutter flutter dialog close dismiss modal dailog flutter showdialog in flutter flutter showdialog builder showdialog flutter and remove programaticallu content showdialog from &lt;widget&gt; flutter content showdialog from is &lt;widget&gt; flutter flutter show modal dialog context flutter show material dialog flutter stateless widget show as dialog+flutter flutter modeldialog show dialog flutter flutter dialog dismiss close showdialog flutter showdialog dart dismiss showdialog flutter dismiss dialog flutter dismiss' dialog flutter showdialog with builder flutter flutter show dialog close dialog flutter showdialog flutter dismiss dialog showDialog flutter flutter showdialog dismiss show dialog flutter on close flutter close dialog close dialog flutter close all showdialogs flutter show dialog flutter close from future show dialog context is required show dialog close flutter
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source