본문 바로가기
개발/Flutter

앱 껐다 켜기 flutter restart app

by dev_caleb 2023. 1. 21.
728x90

앱의 어떤 설정을 바꿨을 때 전체 적용을 위해서 (예를 들어서 테마에 들어가는 색깔을 바꿔줘야한다)

앱을 restart 해줘야하는 경우가 있다. 이런 경우 app을 restart하는 library가 있는지 찾아보았다.

 

https://stackoverflow.com/questions/68504813/how-to-restart-app-with-button-in-flutter

 

How to restart app with button in flutter

I have a setting screen, when I change FontFamily it needs to restart the app to change all app fonts, And it restarts after the app closed, but I want to restart the app with a button instead of c...

stackoverflow.com

 

결과적으로는 아래의 두개의 library를 소개 받았다.

 

https://pub.dev/packages/flutter_phoenix

 

flutter_phoenix | Flutter Package

Easily restart your application from scratch, losing any previous state

pub.dev

https://pub.dev/packages/restart_app

 

restart_app | Flutter Package

A simple package that helps you to restart the whole android app with a single function call.

pub.dev

 

비교적 최근에 나왔고, 자주 관리가 되고 있는 것처럼 보이는 restart_app 을 먼저 설치해보았다!

/// If the [webOrigin] == null, then it uses the [window.origin] to get the site origin.
/// Fill [webOrigin] only when your current origin is different than the app's origin.

굳이 route를 변경할 것은 아니므로 

restart하는 부분에

Restart.restartApp();

이렇게 해주었다!

 

Phoenix도 써봤는데 앱이 완전히 꺼지지가 않고 이상했다.. 그냥 restart_app을 쓰는게 나는 좋다~ 완료!

 

728x90

'개발 > Flutter' 카테고리의 다른 글

Android Studio Code 정리  (0) 2023.02.21
Map 에서 flutter dotdotdot 사용하기  (0) 2023.01.24
GPS 좌표 찍기 사이트 추천!  (0) 2023.01.21
class initializer 각각의 차이점  (0) 2023.01.08
Facebook login  (1) 2022.12.30