Skip to content
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

FormBuilderDropdown using style from CupertinoPicker #243

Closed
brizaldi opened this issue Mar 13, 2020 · 2 comments
Closed

FormBuilderDropdown using style from CupertinoPicker #243

brizaldi opened this issue Mar 13, 2020 · 2 comments

Comments

@brizaldi
Copy link

is there a way to customize FormBuilderDropdown so that it can use style similar to CupertinoPicker when user choose the item?

@danvick
Copy link
Collaborator

danvick commented Mar 27, 2020

As it is currently, the package doesn't support Cupertino style fields.
I would suggest you use FormBuilderCustomField to build your own custom field

@danvick
Copy link
Collaborator

danvick commented Mar 27, 2020

Like so:

var options = ["Option 1", "Option 2", "Option 3"];
FormBuilderCustomField(
  attribute: "name",
  validators: [
    FormBuilderValidators.required(),
  ],
  formField: FormField(
    enabled: true,
    builder: (FormFieldState<dynamic> field) {
      return InputDecorator(
        decoration: InputDecoration(
          labelText: "Select option",
          contentPadding:
              EdgeInsets.only(top: 10.0, bottom: 0.0),
          border: InputBorder.none,
          errorText: field.errorText,
        ),
        child: Container(
          height: 200,
          child: CupertinoPicker(
            itemExtent: 30,
            children: options.map((c) => Text(c)).toList(),
            onSelectedItemChanged: (index) {
              field.didChange(options[index]);
            },
          ),
        ),
      );
    },
  ),
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants