@@ -22,7 +22,7 @@ typedef FileViewerBuilder = Widget Function(
22
22
);
23
23
24
24
/// Field for image(s) from user device storage
25
- class FormBuilderFilePicker extends FormBuilderField <List <PlatformFile >? > {
25
+ class FormBuilderFilePicker extends FormBuilderField <List <PlatformFile >> {
26
26
/// Maximum number of files needed for this field
27
27
final int ? maxFiles;
28
28
@@ -128,7 +128,7 @@ class FormBuilderFilePicker extends FormBuilderField<List<PlatformFile>?> {
128
128
customFileViewerBuilder != null
129
129
? customFileViewerBuilder.call (state._files,
130
130
(files) => state._setFiles (files ?? [], field))
131
- : state.defaultFileViewer (state._files, field),
131
+ : state.defaultFileViewer (state._files, field as FormFieldState < List < PlatformFile >> ),
132
132
],
133
133
),
134
134
);
@@ -212,15 +212,13 @@ class _FormBuilderFilePickerState
212
212
widget.onChanged? .call (_files);
213
213
}
214
214
215
- void removeFileAtIndex (int index, FormFieldState <List <PlatformFile >?> field) {
216
- setState (() {
217
- _files.removeAt (index);
218
- });
215
+ void removeFileAtIndex (int index, FormFieldState <List <PlatformFile >> field) {
216
+ setState (() => _files.removeAt (index));
219
217
field.didChange (_files);
220
218
}
221
219
222
220
Widget defaultFileViewer (
223
- List <PlatformFile > files, FormFieldState <List <PlatformFile >? > field) {
221
+ List <PlatformFile > files, FormFieldState <List <PlatformFile >> field) {
224
222
final theme = Theme .of (context);
225
223
226
224
return LayoutBuilder (
@@ -267,7 +265,7 @@ class _FormBuilderFilePickerState
267
265
width: double .infinity,
268
266
color: Colors .white.withOpacity (.8 ),
269
267
child: Text (
270
- '${ files [index ].name }' ,
268
+ files[index].name,
271
269
style: theme.textTheme.caption,
272
270
maxLines: 2 ,
273
271
overflow: TextOverflow .clip,
0 commit comments