FormBuilderFilePicker constructor
FormBuilderFilePicker({
- Key? key,
- required String name,
- FormFieldValidator<
List< ? validator,PlatformFile> > - List<
PlatformFile> ? initialValue, - InputDecoration decoration = const InputDecoration(),
- ValueChanged<
List< ? onChanged,PlatformFile> ?> - ValueTransformer<
List< ? valueTransformer,PlatformFile> ?> - bool enabled = true,
- FormFieldSetter<
List< ? onSaved,PlatformFile> > - AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
- VoidCallback? onReset,
- FocusNode? focusNode,
- int? maxFiles,
- bool withData = kIsWeb,
- bool withReadStream = false,
- bool allowMultiple = false,
- bool previewImages = true,
- List<
TypeSelector> typeSelectors = const [TypeSelector(type: FileType.any, selector: Icon(Icons.add_circle))], - List<
String> ? allowedExtensions, - void onFileLoading()?,
- bool allowCompression = true,
- FileViewerBuilder? customFileViewerBuilder,
- Widget customTypeViewerBuilder()?,
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)),
],
),
);
},
);