Flutter
[Flutter] Getx, Modal Bottom Sheet, This Obx widget cannot be marked as needing to build beacause the framework is already in the process of building widgets 오류 해결
yo0
2023. 3. 8. 12:34
Obx로 감싸진 버튼을 클릭하면 함수로 Modal Bottom Sheet를 불러오는데 한 번 클릭 했을 때는 문제가 없었는데 두 번 째 클릭했을 때는 해당 오류가 떴다.
Obx((){
...
OnTap:(){
showBottomContainer(context);
}
...
})
showBottomContainer(BuildContext context)
{showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return Container(
);
},
);}
이런 식으로 작성되었었음.
이 함수는 Getx로 관리되는, 즉 Obx로 불러오는데 showModalBottomSheet를 사용하여 또 다시 빌드를 하여 생기는 문제였다.
Obx((){
...
OnTap:(){
showBottomContainer(context);
}
...
})
showBottomContainer(BuildContext context)
{Get.bottomSheet(Container());}