AlertDialog without context in Flutter

前端 未结 4 1935
遥遥无期
遥遥无期 2021-02-02 12:50

I want to show an AlertDialog when a http get fails. The function showDialog (https://api.flutter.dev/flutter/material/showDialog.html) has the parameter \"@required BuildContex

4条回答
  •  無奈伤痛
    2021-02-02 13:12

    The accepted answer is wrong.

    The dialog only needs the context to access it through an inherited navigateState. You can make your own modified dialog, or use this lib to do this.

    https://pub.dev/packages/get

    With it you can open dialog from anywhere in your code without context by doing this:

    Get.dialog(SimpleDialog());
    

提交回复
热议问题