본문 바로가기
개발/Flutter

GetX dialog, bottom sheet 에 controller binding 하기!

by dev_caleb 2022. 8. 11.
728x90

page 에 바인딩하는 것은 get.to 에서 해줘도 되고 router 따로 만들어서 주입시켜줘도 된다. 

 

bottomsheet와 dialog 같은 경우는 어디다가 해줘야할까? 

 

일단 

Get.put(GetxController());

Get.bottomsheet(bottomsheet);

 

이런식으로 코드를 짜면 bottom sheet가 없어지더라도 super 페이지가 닫히지 않으면 controller 가 닫히지 않는다.

 

빌드 위치가 아니면 또 위와 같은 문제가 발생한다. 좋은 것은 빌드 될 때, put 넣어주면

stless 로 bottomsheet 사라지면서 자동으로 controller가 제거가 된다.!

 

내가 생각할 때 제일 동작성 좋은 위치

@override
Widget build(BuildContext context) {
  final InstallmentSettingController installmentSettingController =
  Get.put(InstallmentSettingController());
728x90

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

flutter hive  (0) 2022.08.15
업데이트 시 firebase dynamic link 안 되는 현상  (0) 2022.08.14
TextField filtering  (0) 2022.08.10
if (contain('')) 은 true이다.  (0) 2022.08.10
getX로 debounce 쉽게 쓰는 방법  (0) 2022.08.10