@@ -78,7 +78,7 @@ class FormBuilderFilePicker extends FormBuilderField<List<PlatformFile>> {
78
78
VoidCallback ? onReset,
79
79
FocusNode ? focusNode,
80
80
this .maxFiles,
81
- this .withData = false ,
81
+ this .withData = kIsWeb ,
82
82
this .withReadStream = false ,
83
83
this .allowMultiple = false ,
84
84
this .previewImages = true ,
@@ -111,12 +111,9 @@ class FormBuilderFilePicker extends FormBuilderField<List<PlatformFile>> {
111
111
Row (
112
112
mainAxisAlignment: MainAxisAlignment .spaceBetween,
113
113
children: < Widget > [
114
- if (maxFiles != null )
115
- Text ('${state ._files .length } / $maxFiles ' ),
114
+ if (maxFiles != null ) Text ('${state ._files .length } / $maxFiles ' ),
116
115
InkWell (
117
- onTap: state.enabled &&
118
- (null == state._remainingItemCount ||
119
- state._remainingItemCount! > 0 )
116
+ onTap: state.enabled && (null == state._remainingItemCount || state._remainingItemCount! > 0 )
120
117
? () => state.pickFiles (field)
121
118
: null ,
122
119
child: selector,
@@ -125,10 +122,8 @@ class FormBuilderFilePicker extends FormBuilderField<List<PlatformFile>> {
125
122
),
126
123
const SizedBox (height: 3 ),
127
124
customFileViewerBuilder != null
128
- ? customFileViewerBuilder.call (state._files,
129
- (files) => state._setFiles (files ?? [], field))
130
- : state.defaultFileViewer (state._files,
131
- (files) => state._setFiles (files ?? [], field)),
125
+ ? customFileViewerBuilder.call (state._files, (files) => state._setFiles (files ?? [], field))
126
+ : state.defaultFileViewer (state._files, (files) => state._setFiles (files ?? [], field)),
132
127
],
133
128
),
134
129
);
@@ -139,8 +134,7 @@ class FormBuilderFilePicker extends FormBuilderField<List<PlatformFile>> {
139
134
_FormBuilderFilePickerState createState () => _FormBuilderFilePickerState ();
140
135
}
141
136
142
- class _FormBuilderFilePickerState
143
- extends FormBuilderFieldState <FormBuilderFilePicker , List <PlatformFile >> {
137
+ class _FormBuilderFilePickerState extends FormBuilderFieldState <FormBuilderFilePicker , List <PlatformFile >> {
144
138
/// Image File Extensions.
145
139
///
146
140
/// Note that images may be previewed.
@@ -162,8 +156,7 @@ class _FormBuilderFilePickerState
162
156
163
157
List <PlatformFile > _files = [];
164
158
165
- int ? get _remainingItemCount =>
166
- widget.maxFiles == null ? null : widget.maxFiles! - _files.length;
159
+ int ? get _remainingItemCount => widget.maxFiles == null ? null : widget.maxFiles! - _files.length;
167
160
168
161
@override
169
162
void initState () {
@@ -203,8 +196,7 @@ class _FormBuilderFilePickerState
203
196
}
204
197
}
205
198
206
- void _setFiles (
207
- List <PlatformFile > files, FormFieldState <List <PlatformFile >?> field) {
199
+ void _setFiles (List <PlatformFile > files, FormFieldState <List <PlatformFile >?> field) {
208
200
setState (() => _files = files);
209
201
field.didChange (_files);
210
202
}
@@ -214,16 +206,14 @@ class _FormBuilderFilePickerState
214
206
field.didChange (_files);
215
207
}
216
208
217
- Widget defaultFileViewer (
218
- List <PlatformFile > files, FormFieldSetter <List <PlatformFile >> setter) {
209
+ Widget defaultFileViewer (List <PlatformFile > files, FormFieldSetter <List <PlatformFile >> setter) {
219
210
final theme = Theme .of (context);
220
211
221
212
return LayoutBuilder (
222
213
builder: (context, constraints) {
223
214
const count = 3 ;
224
215
const spacing = 10 ;
225
- final itemSize =
226
- (constraints.biggest.width - (count * spacing)) / count;
216
+ final itemSize = (constraints.biggest.width - (count * spacing)) / count;
227
217
return Wrap (
228
218
// scrollDirection: Axis.horizontal,
229
219
alignment: WrapAlignment .start,
@@ -242,11 +232,10 @@ class _FormBuilderFilePickerState
242
232
children: < Widget > [
243
233
Container (
244
234
alignment: Alignment .center,
245
- child: (imageFileExts.contains (
246
- files[index].extension ! .toLowerCase ()) &&
247
- widget.previewImages)
248
- ? Image .file (File (files[index].path! ),
249
- fit: BoxFit .cover)
235
+ child: (imageFileExts.contains (files[index].extension ! .toLowerCase ()) && widget.previewImages)
236
+ ? kIsWeb
237
+ ? Image .memory (files[index].bytes! , fit: BoxFit .cover)
238
+ : Image .file (File (files[index].path! ), fit: BoxFit .cover)
250
239
: Container (
251
240
alignment: Alignment .center,
252
241
color: theme.primaryColor,
0 commit comments