[Flutter] 탭(페이지) 전환 시 새로고침(리로드) 방지

Taehyun Nam·2021년 12월 7일
0
post-thumbnail

방법

  1. 새로고침(리로드)이 방지 되어야 하는 class에 with AutomaticKeepAliveClientMixin를 추가
  2. class 내부에 @override bool get wantKeepAlive => true 추가

코드 예시

class HelloWorld extends StatefulWidget {
  
  _HelloWorldState createState() => _HelloWorldState();
}

class _HelloWorldState extends State<HelloWorld> with AutomaticKeepAliveClientMixin // (1) 추가 {

  // (2) 추가
  
  bool get wantKeepAlive => true;
  
              .
              .
              .
}
profile
Frontend Developer

0개의 댓글