flutter-form-builder-ecosystem / form_builder_file_picker

File picker field widget for FlutterFormBuilder.
https://pub.dev/packages/form_builder_file_picker
BSD 3-Clause "New" or "Revised" License
15 stars 33 forks source link

add support for multiple type selectors to open different file/image pickers #31

Closed grundid closed 2 years ago

grundid commented 2 years ago

Right now even if one selects FileType.any it is not possible to select images from the photo gallery on mobile devices. Therefore this pull request adds support for multiple buttons to open different file pickers for different file types.

For example:

FormBuilderFilePicker(
  name: "attachments",
  previewImages: false,
  allowMultiple: true,
  withData: true,
  typeSelectors: [
                TypeSelector(
                  type: FileType.any,
                  selector: Row(
                    children: <Widget>[
                      Icon(Icons.add_circle),
                      Padding(
                        padding: const EdgeInsets.only(left: 8.0),
                        child: Text("Add documents"),
                      ),
                    ],
                  ),
                ),
                if (!kIsWeb)
                  TypeSelector(
                    type: FileType.image,
                    selector: Row(
                      children: <Widget>[
                        Icon(Icons.add_photo_alternate),
                        Padding(
                          padding: const EdgeInsets.only(left: 8.0),
                          child: Text("Add images"),
                        ),
                      ],
                    ),
                  ),
              ],
  )
deandreamatias commented 2 years ago

Hi @grundid Thanks for contribution! Can fix the CodeFactor suggestion and add documentation about TypeSelector to Readme?

image

Thanks a lot