Please can anyone assist. We are using FFB for the login and signup areas, and Firebase with GetX statement management. The error below seems to occur adhoc in the application, when typing in the FFB input field. Sometimes it happens, sometimes it doesn't.
I have done some digging around the subject, and the problem is that I am not calling 'setState()' anywhere while input is changing, and therefore not sure how best to ensure that all is mounted before input change and FFB calls setState?
I am using a TextEditingController inside the GetX AuthController as such:
class AuthController extends GetxController { static AuthController to = Get.find(); TextEditingController nameController = TextEditingController(); TextEditingController emailController = TextEditingController(); TextEditingController phoneNumberController = TextEditingController(); TextEditingController passwordController = TextEditingController();
This is the error.
`======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for TextEditingController:
setState() called after dispose(): _FormBuilderTextFieldState#4f765(lifecycle state: defunct, not mounted)
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
When the exception was thrown, this was the stack:
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 236:49 throw
packages/flutter/src/widgets/framework.dart 1231:9
packages/flutter/src/widgets/framework.dart 1265:14 setState
packages/flutter/src/widgets/form.dart 478:5 didChange
packages/flutter_form_builder/src/form_builder_field.dart 162:11 didChange
...
The TextEditingController sending notification was: TextEditingController#25852(TextEditingValue(text: ┤john@jones.com├, selection: TextSelection(baseOffset: -1, extentOffset: -1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1)))
====================================================================================================`
Please can anyone assist. We are using FFB for the login and signup areas, and Firebase with GetX statement management. The error below seems to occur adhoc in the application, when typing in the FFB input field. Sometimes it happens, sometimes it doesn't.
I have done some digging around the subject, and the problem is that I am not calling 'setState()' anywhere while input is changing, and therefore not sure how best to ensure that all is mounted before input change and FFB calls setState?
I am using a TextEditingController inside the GetX AuthController as such:
class AuthController extends GetxController { static AuthController to = Get.find(); TextEditingController nameController = TextEditingController(); TextEditingController emailController = TextEditingController(); TextEditingController phoneNumberController = TextEditingController(); TextEditingController passwordController = TextEditingController();
This is the error. `======== Exception caught by foundation library ==================================================== The following assertion was thrown while dispatching notifications for TextEditingController: setState() called after dispose(): _FormBuilderTextFieldState#4f765(lifecycle state: defunct, not mounted)
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
When the exception was thrown, this was the stack: C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 236:49 throw packages/flutter/src/widgets/framework.dart 1231:9
packages/flutter/src/widgets/framework.dart 1265:14 setState
packages/flutter/src/widgets/form.dart 478:5 didChange
packages/flutter_form_builder/src/form_builder_field.dart 162:11 didChange
...
The TextEditingController sending notification was: TextEditingController#25852(TextEditingValue(text: ┤john@jones.com├, selection: TextSelection(baseOffset: -1, extentOffset: -1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1)))
====================================================================================================`
Thank you in advance