알쓸전컴(알아두면 쓸모있는 전자 컴퓨터)
[Flutter]TabBarView 에서 tab index 변경시 initState 안하기 본문
TabBarView 에서 tab index 변경시 initState 안하기
위와 같이 Tab 에서 index을 움직이고
다시 원래 Index 로 돌아 오면
해당 Widget 객체가 해제 되어 다시 처음 부터
initState 부터 다시 시작 한다.
하지만 텝을 움직여도 이전 위젯상태가 남아 있으면 할때가 있다.
그때는
AutomaticKeepAliveClientMixin 을 with 로 추가 한다음
@override
// TODO: implement wantKeepAlive
bool get wantKeepAlive => true;
해당 함수를 override 하여 위와 같이 true 로 바꿔 주면 된다.
위와 같이 추가 하고
override 한다.
참고 자료 :
https://medium.com/@diegoveloper/flutter-persistent-tab-bars-a26220d322bc
'Flutter,Dart' 카테고리의 다른 글
Flutter Execution failed for task ':firebase_core:verifyReleaseResources' 에러 (1) | 2019.10.23 |
---|---|
Flutter 에서 Android Widgets 불러와서 사용하기 (1) | 2019.10.16 |
[Flutter] FutureBuilder에서 setState 할때 future 초기화 제외 하기 (1) | 2019.08.01 |
Flutter Json DeSerializable 와 Json List DeSerializable (0) | 2019.07.18 |
[Flutter,Dart](신)동네예보정보조회서비스 기상청 API,위도 경도->좌표 (0) | 2019.07.03 |
Comments