File tree Expand file tree Collapse file tree 2 files changed +5
-771
lines changed Expand file tree Collapse file tree 2 files changed +5
-771
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class FileImportContainer extends StatefulWidget {
2121 this .onAction,
2222 this .onFileSelected,
2323 this .onError,
24+ this .extensions = const ['json' ],
2425 Key key,
2526 }) : super (key: key);
2627
@@ -37,6 +38,9 @@ class FileImportContainer extends StatefulWidget {
3738
3839 final void Function (String error) onError;
3940
41+ // The file's extensions where we are going to get the data from.
42+ final List <String > extensions;
43+
4044 @override
4145 _FileImportContainerState createState () => _FileImportContainerState ();
4246}
@@ -176,9 +180,7 @@ class _FileImportContainerState extends State<FileImportContainer> {
176180 }
177181
178182 void _importFile () async {
179- final acceptedTypeGroups = [
180- XTypeGroup (extensions: ['json' ])
181- ];
183+ final acceptedTypeGroups = [XTypeGroup (extensions: widget.extensions)];
182184 final file = await openFile (acceptedTypeGroups: acceptedTypeGroups);
183185 final data = jsonDecode (await file.readAsString ());
184186 final lastModifiedTime = await file.lastModified ();
You can’t perform that action at this time.
0 commit comments