Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- window
- darkmode
- Apple
- IOS
- Realm
- MacOS
- 웹뷰
- Session
- 개발자
- 한글
- iOS16
- error
- Firebase
- 이미지
- github
- Xcode
- Git
- JPA
- rxswift
- Archive
- mac
- Swift
- UIButton
- Code
- geofencing
- SwiftUI
- view
- Notification
- appstore
- FLUTTER
Archives
- Today
- Total
EEYatHo 앱 깎는 이야기
Flutter ) 탭바 돌아와도 initState 안하기 - EEYatHo Flutter 본문
반응형
DefaultTabController 를 기반으로 탭바를 구현했을 때,
다른 탭으로 가면 기존에 보이던 화면이 dispose (deinit) 된다.
그래서 다시 돌아왔을 때는 initState 부터 시작한다.
이를 방지하기 위해, 다른 탭에가도 dispose 되지 않게 할 수 있다.
Solution
dispose 되지 않길 바라는 화면의 State 에 AutomaticKeepAliveClientMixin 을 Mixin 하고,
wantKeepAlive 를 true 로 override 해준다.
// dispose 되지 않길 바라는 화면의 State
class _SomeTabState extends State<SomeTab> with AutomaticKeepAliveClientMixin {
...
// 다른 탭 갔다와도 dispose 안하기 ( with AutomaticKeepAliveClientMixin )
@override
bool get wantKeepAlive => true;
...
}
'Flutter > Tip' 카테고리의 다른 글
Flutter ) OS 구분 - EEYatHo Flutter (0) | 2022.09.21 |
---|