2017-05-24 23 views
5

私は以下のAlertDialogを持っています。フラットボタンクリックでAlertDialogを解除するにはどうすればよいですか?

showDialog(
      context: context, 
      child: new AlertDialog(
       title: const Text("Location disabled"), 
       content: const Text(
        """ 
Location is disabled on this device. Please enable it and try again. 
        """), 
       actions: [ 
       new FlatButton(
        child: const Text("Ok"), 
        onPressed: _dismissDialog, 
       ), 
       ], 
      ), 
     ); 

どのように_dismissDialog()を作成すると、AlertDialogを終了できますか?

答えて

5

Navigator.pop()トリックを行う必要があります。ダイアログの結果を返すこともできます(選択肢をユーザに提示した場合)

+0

ありがとうございました。 Navigator.pop()を呼び出すと、ダイアログが正常に閉じられます。私の現在のonPressedは次の通りです: 'onPressed :()=> Navigator.pop(context)、' – Gustash

関連する問題