在外部单击时如何关闭警报对话框

问题描述 投票:-1回答:1

我有一个警报对话框,我想在其外部单击时将其关闭,我知道这是抖动对话框中默认的行为,但是我不知道是什么问题阻止了其在外部单击时关闭。

我尝试将barrierDismissable设置为true,但仍然无法正常工作。

This is my dialog : 

termsAndConditionsDialog(BuildContext context) {

    AlertDialog alert = AlertDialog(
      title:  Text("Terms and Conditions", style: TextStyle(fontSize: 18, color: AppColors.accentColor),),
      content: Text(
        generalSettings.policyForCustomer,
        style: TextStyle(fontSize: 16),
      ),

    );


    // show the dialog
    showDialog(
      barrierDismissible: true,
      context: context,
      builder: (BuildContext context) {
        return alert;
      },
    );
  }


and this is how I call it from button's onPressed : 
 termsAndConditionsDialog(context);
flutter dialog android-alertdialog flutter-layout flutter-alertdialog
1个回答
0
投票

在onPressed或onTap上调用此方法:

© www.soinside.com 2019 - 2024. All rights reserved.