2017-05-24 1 views
5

다음 AlertDialog 있습니다.FlatButton 클릭시 AlertDialog를 닫을 수 있습니까?

showDialog(
      context: context, 
      child: new AlertDialog(
       title: const Text("Location disabled"), 
       content: const Text(
        """ 
Location is disabled on this device. Please enable it and try again. 
        """), 
       actions: [ 
       new FlatButton(
        child: const Text("Ok"), 
        onPressed: _dismissDialog, 
       ), 
       ], 
      ), 
     ); 

는 _dismissDialog()에 AlertDialog 말했다 해제를 어떻게 만들 수 ?

답변

5

Navigator.pop() 트릭을해야합니다. 대화 상자의 결과를 반환 할 수도 있습니다 (사용자에게 선택 사항을 제시 한 경우)

+0

감사합니다. Navigator.pop()을 호출하면 대화 상자가 예상대로 닫힙니다. 내 현재 onPressed는 다음과 같습니다 : 'onPressed :() => Navigator.pop (context),' – Gustash

관련 문제