Created
August 1, 2023 00:10
-
-
Save quangpd/737eef46ffe6b61fb8c902f8a6e698b3 to your computer and use it in GitHub Desktop.
await Future.delayed(Duration.zero); // prevent setState() or markNeedsBuild() error with Getx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is because you are trying to update an observable value while the widget tree is getting built, this is probably caused because of the method | |
GetBuilder<CustomerServiceController>( | |
init: CustomerServiceController(), | |
initState: (state) async { // Here | |
await Future.delayed(Duration.zero); // And here | |
var service = Get.find<CustomerServiceController>(); | |
if (customerService != null) { | |
service.nameTextController.text = customerService.title; | |
service.descriptionTextController.text = | |
customerService.description; | |
service.priceTextController.text = customerService.price; | |
service.endTextController.text = | |
customerService.endDate ?? ''; | |
service.serviceCategory = customerService.category!; | |
service.serviceType = customerService.service!; | |
service.serviceProvider = customerService.provider!; | |
service.isSubscription = customerService.isSubscription!; | |
} else { | |
service.nameTextController.text = ''; | |
service.descriptionTextController.text = ''; | |
service.priceTextController.text = ''; | |
service.endTextController.text = ''; | |
} | |
}, | |
builder: (controller) { | |
return Column(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment