Closed LefebvreIlyas closed 2 years ago
You are right, using setState
would be expensive when a Formbuilder containing many textfields in a StatefulWidget
, it sometime costs you an unexpected rebuild.
You can consider using state management method like States_rebuilder, Bloc.
Yes that's true, but I just wanted to use FormBuilder. Even if I use Cubit for the state management of the app.
@LefebvreIlyas did you solve this? can you share?
Sorry for the late reply @nirbar89.
I use flutter_form_builder
to dispatch the data in the different fields BUT I use a cubit
to collect the new values of the different fields and make the validation. And so at each change I rebuild the view, which corresponds to the idea of @amoslai5128.
You can replace the cubit
by something else of course, the principle remains the same.
The solution is quite reactive whether on mobile or web.
If my message is not very clear, tell me and I will make a code example to illustrate my solution.
Have a nice day.
Sorry for the late reply @nirbar89.
I use
flutter_form_builder
to dispatch the data in the different fields BUT I use acubit
to collect the new values of the different fields and make the validation. And so at each change I rebuild the view, which corresponds to the idea of @amoslai5128.You can replace the
cubit
by something else of course, the principle remains the same.The solution is quite reactive whether on mobile or web.
If my message is not very clear, tell me and I will make a code example to illustrate my solution.
Have a nice day.
Hey, thank you very much.
I will be more then happy to see an example
Sorry for the late reply @nirbar89. I use
flutter_form_builder
to dispatch the data in the different fields BUT I use acubit
to collect the new values of the different fields and make the validation. And so at each change I rebuild the view, which corresponds to the idea of @amoslai5128. You can replace thecubit
by something else of course, the principle remains the same. The solution is quite reactive whether on mobile or web. If my message is not very clear, tell me and I will make a code example to illustrate my solution. Have a nice day.Hey, thank you very much.
I will be more then happy to see an example
@LefebvreIlyas @nirbar89
I've seen an example by using States_rebuilders, every textfeild has a state to rebuild independently and hooks up outside the widget tree.
On.form(
() => Column(
children: <Widget>[
TextField(
focusNode: email.focusNode,
controller: email.controller,
onSubmitted: (_) {
password.focusNode.requestFocus();
},
),
TextField(
focusNode: password.focusNode,
controller: password.controller,
onSubmitted: (_) {
form.submitFocusNode.requestFocus();
},
),
],
),
).listenTo(form),
This still a issue?
Due to lack of response and an old error, I will close this issue. If the bug still exists, feel free to open a new issue
Hello !
I need to build a form composed of several fields divided into sections (steps). Since there can be many section fields, I use a
ListView.builder
, and each section is a page in aPageView.builder
.Here is the structure:
In order not to lose the data I store them in a buffer dictionary. But when the user returns to a section, the fields he has filled in are now empty. It would be necessary to make a
setState
, but this is very expensive.Sample code
```dart import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; final ListDoes anyone have a better implementation / idea?
When the user navigates through the form through the different fields in a more advanced example, this error occurs:
Error
``` Error: A FocusNode was used after being disposed. Once you have called dispose() on a FocusNode, it can no longer be used. at Object.throw_ [as throw] (http://localhost:49921/dart_sdk.js:4193:11) at http://localhost:49921/packages/flutter/src/foundation/change_notifier.dart.lib.js:66:21 at focus_manager.FocusNode.new.[_debugAssertNotDisposed] (http://localhost:49921/packages/flutter/src/foundation/change_notifier.dart.lib.js:69:23) at focus_manager.FocusNode.new.notifyListeners (http://localhost:49921/packages/flutter/src/foundation/change_notifier.dart.lib.js:96:51) at focus_manager.FocusNode.new.[_notify] (http://localhost:49921/packages/flutter/src/widgets/widget_span.dart.lib.js:46860:12) at focus_manager.FocusManager.new.[_applyFocusChange] (http://localhost:49921/packages/flutter/src/widgets/widget_span.dart.lib.js:47674:22) at Object._microtaskLoop (http://localhost:49921/dart_sdk.js:36245:13) at _startMicrotaskLoop (http://localhost:49921/dart_sdk.js:36251:13) at http://localhost:49921/dart_sdk.js:31999:9 ```