민프
[Flutter] dispose() 는 왜쓰는걸까? 본문
https://api.flutter.dev/flutter/widgets/State/dispose.html
dispose method - State class - widgets library - Dart API
void dispose() Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again. After the framework calls dispose, the State object is considered unmounted and the mounted property
api.flutter.dev
Flutter 공식 문서를 참고하면
각 객체가 제거 될 때 변수에 할당 된 메모리를 해제하기 위해 사용된다.
즉, 각 페이지마다 Controller, FocusNode등.. 을 사용하고 dispose해주게 되면 메모리 관리가 된다는 말 이다.
@override
void dispose() {
// TODO: implement dispose
super.dispose();
//선택 된 위젯을 관리하는 FocusNode
_nicknameFocus.dispose();
_birthFocus.dispose();
_jobFocus.dispose();
//, 패스워드, 패스워드 확인 컨트롤러
_nicknameController.dispose();
_birthController.dispose();
_jobController.dispose();
}
'Frontend > [Flutter]' 카테고리의 다른 글
[Flutter] http 통신 GET,POST해보기 (2) | 2023.01.09 |
---|---|
[Flutter] Switch 버튼 종류 (0) | 2023.01.09 |
[Flutter] Button에 Ripple(물결)효과 없애보기 (0) | 2023.01.02 |
[Flutter] Flutter 이미지 피커를 적용해보자! (feat. Error: Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)) (1) | 2022.12.26 |
[Flutter] String to Uri (0) | 2022.12.09 |
Comments