mirror of
https://github.com/foss42/apidash.git
synced 2025-12-10 15:23:19 +08:00
Show error snackbar on import failure
This commit is contained in:
@@ -19,6 +19,7 @@ class CollectionPane extends ConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final collection = ref.watch(collectionStateNotifierProvider);
|
final collection = ref.watch(collectionStateNotifierProvider);
|
||||||
|
var sm = ScaffoldMessenger.of(context);
|
||||||
if (collection == null) {
|
if (collection == null) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
@@ -47,7 +48,7 @@ class CollectionPane extends ConsumerWidget {
|
|||||||
},
|
},
|
||||||
onFileDropped: (file) {
|
onFileDropped: (file) {
|
||||||
final importFormatType = ref.read(importFormatStateProvider);
|
final importFormatType = ref.read(importFormatStateProvider);
|
||||||
String? msg;
|
sm.hideCurrentSnackBar();
|
||||||
file.readAsString().then(
|
file.readAsString().then(
|
||||||
(content) {
|
(content) {
|
||||||
kImporter
|
kImporter
|
||||||
@@ -58,18 +59,17 @@ class CollectionPane extends ConsumerWidget {
|
|||||||
.read(collectionStateNotifierProvider.notifier)
|
.read(collectionStateNotifierProvider.notifier)
|
||||||
.addRequestModel(importedRequestModel);
|
.addRequestModel(importedRequestModel);
|
||||||
} else {
|
} else {
|
||||||
msg = "Unable to parse ${file.name}";
|
var err = "Unable to parse ${file.name}";
|
||||||
|
sm.showSnackBar(getSnackBar(err, small: false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: (e) {
|
onError: (e) {
|
||||||
msg = "Unable to import ${file.name}";
|
var err = "Unable to import ${file.name}";
|
||||||
|
sm.showSnackBar(getSnackBar(err, small: false));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
if (msg != null) {
|
|
||||||
showTextDialog(context, content: msg);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user