-
-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FormBuilderCustomField: how to add a textfield to a FormBuilderRadio? #60
Comments
Hi @maciejkos, Here was my approach on dealing with this issue: First, we define a Then: FormBuilderCustomField(
attribute: 'custom',
valueTransformer: (val){
if(val == "Other")
return _specifyTextFieldKey.currentState.value;
return val;
},
formField: FormField(
builder: (FormFieldState<String> field) {
var languages = ["English", "Spanish", "Somali", "Other"];
return InputDecorator(
decoration: InputDecoration(
labelText: "What's your preferred language?"),
child: Column(
children: languages.map((lang) =>
Row(
children: <Widget>[
Radio<dynamic>(
value: lang,
groupValue: field.value,
onChanged: (dynamic value) {
field.didChange(lang);
},
),
Expanded(
child: lang != "Other" ? Text(lang) : Row(
children: <Widget>[
Text(
lang,
),
SizedBox(width: 20),
Expanded(
child: TextFormField(key: _specifyTextFieldKey,),
),
],
),
),
],
),
).toList(growable: false),
),
);
},
),
), Explanation:
|
Some follow-up if you don't mind - after observing the solution provided here - what do you think we can provide in the documentation to improve the experience when using the I feel like So if the documentation of Thanks in advance. |
Thank you so much, @danvick! I will test this soon and reply to your feedback request within the next 7 days. My current sprint ends Monday evening. Thanks again! |
Thank you again, @danvick. To give you some context, I specialize in data science (R/Python). This is the first mobile application I am writing by myself; I have never used Flutter/Dart before. The app includes about 80 questions which I generate by parsing a JSON file. Your package is a perfect choice for folks like me because it really simplifies making forms. If your target audience is Flutter/Dart beginners, what would help are:
I hope this helps! |
Hi,
I am using your excellent package in my first Flutter app. However, I do have some trouble using the
FormBuilderCustomField
.I would like to create a form combining
![Prototype](https://camo.githubusercontent.com/e2ffd205113e61548bb0dd83b15ccf0f535f0c7ac44991b59d5b678b8ac5dd07/68747470733a2f2f692e696d6775722e636f6d2f4769486554724b2e706e67)
FormBuilderTextField
andFormBuilderRadio
. Below is the desired output.At this point, I don't care about validating the
textfield
itself.Could you please give me a few pointers? I haven't found any code snippets beyond what is in the README. Thank you!
The text was updated successfully, but these errors were encountered: