FormBuilderFilePicker constructor

FormBuilderFilePicker({
  1. Key? key,
  2. required String name,
  3. FormFieldValidator<List<PlatformFile>>? validator,
  4. List<PlatformFile>? initialValue,
  5. InputDecoration decoration = const InputDecoration(),
  6. ValueChanged<List<PlatformFile>?>? onChanged,
  7. ValueTransformer<List<PlatformFile>?>? valueTransformer,
  8. bool enabled = true,
  9. FormFieldSetter<List<PlatformFile>>? onSaved,
  10. AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
  11. VoidCallback? onReset,
  12. FocusNode? focusNode,
  13. int? maxFiles,
  14. bool withData = kIsWeb,
  15. bool withReadStream = false,
  16. bool allowMultiple = false,
  17. bool previewImages = true,
  18. List<TypeSelector> typeSelectors = const [TypeSelector(type: FileType.any, selector: Icon(Icons.add_circle))],
  19. List<String>? allowedExtensions,
  20. void onFileLoading(
    1. FilePickerStatus
    )?,
  21. bool allowCompression = true,
  22. FileViewerBuilder? customFileViewerBuilder,
  23. Widget customTypeViewerBuilder(
    1. List<Widget> types
    )?,
})

Creates field for image(s) from user device storage

Implementation

FormBuilderFilePicker(
    {
    //From Super
    super.key,
    required super.name,
    super.validator,
    super.initialValue,
    super.decoration,
    super.onChanged,
    super.valueTransformer,
    super.enabled,
    super.onSaved,
    super.autovalidateMode = AutovalidateMode.disabled,
    super.onReset,
    super.focusNode,
    this.maxFiles,
    this.withData = kIsWeb,
    this.withReadStream = false,
    this.allowMultiple = false,
    this.previewImages = true,
    this.typeSelectors = const [
      TypeSelector(type: FileType.any, selector: Icon(Icons.add_circle))
    ],
    this.allowedExtensions,
    this.onFileLoading,
    this.allowCompression = true,
    this.customFileViewerBuilder,
    this.customTypeViewerBuilder})
    : super(
        builder: (FormFieldState<List<PlatformFile>?> field) {
          final state = field as _FormBuilderFilePickerState;

          return InputDecorator(
            decoration: state.decoration.copyWith(
                counterText: maxFiles != null
                    ? '${state._files.length} / $maxFiles'
                    : null),
            child: Column(
              children: <Widget>[
                customTypeViewerBuilder != null
                    ? customTypeViewerBuilder(
                        state.getTypeSelectorActions(typeSelectors, field))
                    : Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: state.getTypeSelectorActions(
                            typeSelectors, field),
                      ),
                const SizedBox(height: 3),
                customFileViewerBuilder != null
                    ? customFileViewerBuilder.call(state._files,
                        (files) => state._setFiles(files ?? [], field))
                    : state.defaultFileViewer(state._files,
                        (files) => state._setFiles(files ?? [], field)),
              ],
            ),
          );
        },
      );