본문 바로가기

Flutter

[j Flutter ] 앱 종료하기

728x90
반응형
Future<bool> _onBackPressed() {
    return showDialog(
          context: context,
          builder: (context) => AlertDialog(
            title: Text("종료하시겠습니까?"),
            actions: <Widget>[
              FlatButton(
                child: Text("종료하기"),
                onPressed: () => SystemChannels.platform.invokeMethod('SystemNavigator.pop'),
              ),
              FlatButton(
                child: Text("취소"),
                onPressed: () => Navigator.pop(context, false),
              ),
            ],
          ),
        ) ??
        false;
  }
728x90
반응형