@@ -97,12 +97,12 @@ class FormBuilderFilePicker extends FormBuilderField<List<PlatformFile>> {
97
97
if (maxFiles != null )
98
98
Text ('${state ._files .length } / $maxFiles ' ),
99
99
InkWell (
100
- child: selector,
101
100
onTap: state.enabled &&
102
101
(null == state._remainingItemCount ||
103
102
state._remainingItemCount > 0 )
104
103
? () => state.pickFiles (field)
105
104
: null ,
105
+ child: selector,
106
106
),
107
107
],
108
108
),
@@ -226,24 +226,24 @@ class _FormBuilderFilePickerState
226
226
fit: BoxFit .cover)
227
227
: Container (
228
228
alignment: Alignment .center,
229
+ color: theme.primaryColor,
229
230
child: Icon (
230
231
getIconData (files[index].extension ),
231
232
color: Colors .white,
232
233
size: 56 ,
233
234
),
234
- color: theme.primaryColor,
235
235
),
236
236
),
237
237
Container (
238
238
padding: const EdgeInsets .symmetric (horizontal: 2 ),
239
+ width: double .infinity,
240
+ color: Colors .white.withOpacity (.8 ),
239
241
child: Text (
240
242
files[index].name,
241
243
style: theme.textTheme.caption,
242
244
maxLines: 2 ,
243
245
overflow: TextOverflow .clip,
244
246
),
245
- width: double .infinity,
246
- color: Colors .white.withOpacity (.8 ),
247
247
),
248
248
if (enabled)
249
249
Positioned (
@@ -279,20 +279,25 @@ class _FormBuilderFilePickerState
279
279
}
280
280
281
281
IconData getIconData (String fileExtension) {
282
+ final lowerCaseFileExt = fileExtension.toLowerCase ();
283
+ if (imageFileExts.contains (lowerCaseFileExt)) return Icons .image;
282
284
// Check if the file is an image first (because there is a shared variable
283
285
// with preview logic), and then fallback to non-image file ext lookup.
284
- const nonImageFileExtIcons = {
285
- 'doc' : CommunityMaterialIcons .file_word,
286
- 'docx' : CommunityMaterialIcons .file_word,
287
- 'log' : CommunityMaterialIcons .script_text,
288
- 'pdf' : CommunityMaterialIcons .file_pdf,
289
- 'txt' : CommunityMaterialIcons .script_text,
290
- 'xls' : CommunityMaterialIcons .file_excel,
291
- 'xlsx' : CommunityMaterialIcons .file_excel,
292
- };
293
- final lowerCaseFileExt = fileExtension.toLowerCase ();
294
- return imageFileExts.contains (lowerCaseFileExt)
295
- ? Icons .image
296
- : nonImageFileExtIcons[lowerCaseFileExt] ?? Icons .insert_drive_file;
286
+ switch (lowerCaseFileExt) {
287
+ case 'doc' :
288
+ case 'docx' :
289
+ return CommunityMaterialIcons .file_word;
290
+ case 'log' :
291
+ return CommunityMaterialIcons .script_text;
292
+ case 'pdf' :
293
+ return CommunityMaterialIcons .file_pdf;
294
+ case 'txt' :
295
+ return CommunityMaterialIcons .script_text;
296
+ case 'xls' :
297
+ case 'xlsx' :
298
+ return CommunityMaterialIcons .file_excel;
299
+ default :
300
+ return Icons .insert_drive_file;
301
+ }
297
302
}
298
303
}
0 commit comments