{"id":28812584,"url":"https://github.com/tpdlshdmlrkfmcla/flutter-backbutton","last_synced_at":"2026-05-16T11:03:23.910Z","repository":{"id":138422872,"uuid":"593045336","full_name":"tpdlshdmlrkfmcla/Flutter-BackButton","owner":"tpdlshdmlrkfmcla","description":"Flutter 앱 두 번 뒤로가기로 앱 종료하는 법","archived":false,"fork":false,"pushed_at":"2023-01-25T06:00:13.000Z","size":295,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-24T05:35:58.137Z","etag":null,"topics":["backbutton","flutter"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tpdlshdmlrkfmcla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-01-25T04:56:14.000Z","updated_at":"2023-01-25T06:02:58.000Z","dependencies_parsed_at":"2023-08-20T14:07:04.766Z","dependency_job_id":null,"html_url":"https://github.com/tpdlshdmlrkfmcla/Flutter-BackButton","commit_stats":null,"previous_names":["wonttan/flutter-backbutton","wonchihyeon/flutter-backbutton","chihyunwon/flutter-backbutton","mr-won/flutter-backbutton","chihyeonwon/flutter-backbutton","user20252228/flutter-backbutton","tpdlshdmlrkfmcla/flutter-backbutton"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tpdlshdmlrkfmcla/Flutter-BackButton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpdlshdmlrkfmcla%2FFlutter-BackButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpdlshdmlrkfmcla%2FFlutter-BackButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpdlshdmlrkfmcla%2FFlutter-BackButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpdlshdmlrkfmcla%2FFlutter-BackButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tpdlshdmlrkfmcla","download_url":"https://codeload.github.com/tpdlshdmlrkfmcla/Flutter-BackButton/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpdlshdmlrkfmcla%2FFlutter-BackButton/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33100319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backbutton","flutter"],"created_at":"2025-06-18T14:41:26.778Z","updated_at":"2026-05-16T11:03:23.884Z","avatar_url":"https://github.com/tpdlshdmlrkfmcla.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# backbutton\n\n```\n보통의 앱들은 뒤로가기 버튼을 눌러서 앱 종료를 할 때 \n사용자들의 앱 종료 의사를 한번 더 물어보고 종료를 합니다.\n\n뒤로가기 버튼을 눌렀을 때 토스트 형식의 메시지를 출력하면서\n앱 종료 의사를 한 번더 물어보는 기능을 추가해보았습니다.\n\n뒤로 가기 버튼 한번 -\u003e 토스트 메시지 출력(정말로 종료하시겠습니까?)\n토스트 메시지가 출력된 후 2초 안에 뒤로 가기 버튼 한번 더 (앱 종료)\n```\n![image](https://user-images.githubusercontent.com/58906858/214491243-6a7111c8-da47-402c-80e6-09099e614fc9.png)\n\n\n## 필요한 패키지 추가\n```\n토스트 메시지를 띄우기 위한 fluttertoast를\n추가하였습니다.  \n```\n![image](https://user-images.githubusercontent.com/58906858/214489286-4f8dd691-4ced-4671-9d68-a8fa5c65a33d.png)\n\n## 토스트 함수 로직 \n```\n뒤로가기 한번을 누르고 2초안에 한 번더 누르면 앱이 종료되어야 하기 때문에\n현재 시간을 now로 선언하고 difference 메소드를 사용해서 시간 차이를 구해주었습니다.\n2초 안에 뒤로가기 버튼을 두 번 누르지 않으면 toast 메시지가 출력됩니다.\n```\n![image](https://user-images.githubusercontent.com/58906858/214489622-d3b0215e-a37c-4ba8-83fb-ad18d01c318b.png)\n\n## WillPopScope의 사용\n```\nWillPopScope를 사용하면 Scaffold 위젯을 감싸서 뒤로가기 버튼을 가로챌 수 있습니다.\n위에서 생성한 함수를 onWillPop 프로퍼티의 값으로 전달하고 onWillPop 함수의 리턴값이 true일때\n뒤로가기 버튼이 작용하여 앱이 종료됩니다. false일 때는 화면에 남게 됩니다(2초 동안 뒤로가기 버튼이 안눌러졌을때).\n```\n![image](https://user-images.githubusercontent.com/58906858/214491237-0985f6ec-197c-4f7d-951b-4e1bbd392de3.png)\n\n## 향후 프로젝트에 어떻게 사용할 것인가?\n```\n향후 프로젝트에서 메인 페이지에 위의 코드를 util 폴더에 담은 뒤에 사용해서 \n사용자에게 편의를 줄 수 있을 것으로 예상합니다.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpdlshdmlrkfmcla%2Fflutter-backbutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftpdlshdmlrkfmcla%2Fflutter-backbutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpdlshdmlrkfmcla%2Fflutter-backbutton/lists"}