AlertDialog without context in Flutter

前端 未结 4 1934
遥遥无期
遥遥无期 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:16

    Catch the exception where you make the getNews call if you use await, else use the catchError property of the Future.

提交回复
热议问题