I am making a web page and I have a RxList. I wrap the widget using the list in an obx but whenever I navigate to the page containing the widget it does not show the page at all from the very beginning (even before changing the list) and it freezes. It always show the following message in my console:
Assertion failed: file:///Users/alitimajchi/Desktop/flutter/packages/flutter/lib/src/rendering/box.dart:1935:13 debugDoingThisResize || debugDoingThisLayout || _computingThisDryLayout || (RenderObject.debugActiveLayout == parent && _size._canBeUsedByParent) "RenderBox.size accessed beyond the scope of resize, layout, or permitted parent access. RenderBox can always access its own size, otherwise, the only object that is allowed to read RenderBox.size is its parent, if they have said they will. It you hit this assert trying to access a child's size, pass "parentUsesSize: true" to that child's layout()."
And if I remove the obx the error goes away but the ui won't update. I also tried different type of data type (for example RxBool) and it worked fine. But I don't know how to solve the problem with RxList.
Here is my code:
class Controller extends GetxController{
RxList<bool> list = <bool>[false].obs;
updatelist(){
list.insert(0, !list.first);
list.removeAt(0);
}
}
class View extends StatelessWidget{
final Controller controller = Get.find();
build(BuildContext context){
return Obx( () =>TextField(
enabled: controller.list.elementAt(0)
onChanged: (_) => controller.updateList()
));
}
}
flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Connected device (1 available)
• No issues found!
My get version in 4.6.1 I am using Android Studio on a macbook air 2015 with macOS Monterey 12.1. I also tried GetX and GetBuilder and neither of them worked. Thanks in advance :).