Show error message for incorrect file import

This commit is contained in:
Ashita Prasad
2024-12-06 05:27:13 +05:30
parent 5ece558d23
commit 8315d57e79

View File

@ -47,7 +47,8 @@ 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(
(content) {
kImporter kImporter
.getHttpRequestModel(importFormatType, content) .getHttpRequestModel(importFormatType, content)
.then((importedRequestModel) { .then((importedRequestModel) {
@ -56,10 +57,16 @@ class CollectionPane extends ConsumerWidget {
.read(collectionStateNotifierProvider.notifier) .read(collectionStateNotifierProvider.notifier)
.addRequestModel(importedRequestModel); .addRequestModel(importedRequestModel);
} else { } else {
// TODO: Throw an error, unable to parse // 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();
}, },
); );