۳ مجتبی نامدارپوربنگر
alert dialog error
جامعه فلاتر ایجاد شده در ۰۸ آذر ۱۴۰۱

سلام

من از alert dialog استفاده کردم که موقع اجرا وقتی روی دکمه yes یا میزنم موقع اجرای دستور  Navigator.of(context).pop(); خطا میده

سلام

لطفا کدتون رو بفرستید

یلدا محصلی ۰۸ آذر ۱۴۰۱، ۰۵:۲۳

showAlertDialog(BuildContext context) {

  // set up the buttons

  Widget yesButton = TextButton(

    child: Text("بلی"),

    onPressed: () {

      //task.delete();

      Navigator.of(context).pop();

    },

  );

  Widget noButton = TextButton(

    child: Text("خیر"),

    onPressed: () {

      Navigator.of(context).pop();

    },

  );


  // set up the AlertDialog

  AlertDialog alert = AlertDialog(

    title: Text(""),

    content: Text("آیا کار حذف شود؟"),

    actions: [

      yesButton,

      noButton,

    ],

  );


  // show the dialog

  showDialog(

    context: context,

    builder: (BuildContext context) {

      return alert;

    },

  );

}

و نحوه استفاده

showAlertDialog(context);

مجتبی نامدارپوربنگر ۰۸ آذر ۱۴۰۱، ۰۵:۲۷

من از کدتون در قسمت onLongPress استفاده کردم، مشکلی نداشت. احتمالا جای مناسبی فراخوانی نمی‌کنید که به ارور میخورید.

یلدا محصلی ۰۸ آذر ۱۴۰۱، ۰۵:۵۴