mirror of
https://github.com/foss42/apidash.git
synced 2025-06-05 01:46:21 +08:00
Show error message for incorrect file import
This commit is contained in:
@ -47,19 +47,26 @@ class CollectionPane extends ConsumerWidget {
|
|||||||
},
|
},
|
||||||
onFileDropped: (file) {
|
onFileDropped: (file) {
|
||||||
final importFormatType = ref.read(importFormatStateProvider);
|
final importFormatType = ref.read(importFormatStateProvider);
|
||||||
file.readAsString().then((content) {
|
file.readAsString().then(
|
||||||
kImporter
|
(content) {
|
||||||
.getHttpRequestModel(importFormatType, content)
|
kImporter
|
||||||
.then((importedRequestModel) {
|
.getHttpRequestModel(importFormatType, content)
|
||||||
if (importedRequestModel != null) {
|
.then((importedRequestModel) {
|
||||||
ref
|
if (importedRequestModel != null) {
|
||||||
.read(collectionStateNotifierProvider.notifier)
|
ref
|
||||||
.addRequestModel(importedRequestModel);
|
.read(collectionStateNotifierProvider.notifier)
|
||||||
} else {
|
.addRequestModel(importedRequestModel);
|
||||||
// TODO: Throw an error, unable to parse
|
} else {
|
||||||
}
|
// TODO: show in status bar
|
||||||
});
|
debugPrint("Unable to parse ${file.name}");
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onError: (e) {
|
||||||
|
// TODO: show in status bar
|
||||||
|
debugPrint("Unable to import ${file.name}");
|
||||||
|
},
|
||||||
|
);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user