diff --git a/lib/redux/document/document_actions.dart b/lib/redux/document/document_actions.dart index 40549108b..9ae19f112 100644 --- a/lib/redux/document/document_actions.dart +++ b/lib/redux/document/document_actions.dart @@ -436,7 +436,9 @@ void handleDocumentAction( final DocumentEntity? document = store.state.documentState.map[documentIds.first]; if (kIsWeb) { - WebUtils.downloadBinaryFile(document!.name, document.data); + if (document?.data != null) { + WebUtils.downloadBinaryFile(document!.name, document.data!); + } } else { final directory = await (isDesktopOS() ? getDownloadsDirectory() as FutureOr diff --git a/lib/utils/web.dart b/lib/utils/web.dart index 4a3454136..9ffb535f9 100644 --- a/lib/utils/web.dart +++ b/lib/utils/web.dart @@ -53,18 +53,18 @@ class WebUtils { static void reloadBrowser() => window.location.reload(); - static void registerWebView(String html) { + static void registerWebView(String? html) { // ignore: undefined_prefixed_name ui.platformViewRegistry.registerViewFactory( - html, + html ?? '', (int viewId) => IFrameElement() ..src = html ..style.border = 'none'); } - static void warnChanges(Store store) { + static void warnChanges(Store? store) { window.onBeforeUnload.listen((Event e) { - if (store.state.hasChanges()) { + if (store!.state.hasChanges()) { (e as BeforeUnloadEvent).returnValue = 'Changes you made may not be saved.'; } diff --git a/lib/utils/web_stub.dart b/lib/utils/web_stub.dart index b06953b12..af224f4ce 100644 --- a/lib/utils/web_stub.dart +++ b/lib/utils/web_stub.dart @@ -18,7 +18,7 @@ class WebUtils { static void downloadTextFile(String filename, String data) {} - static void downloadBinaryFile(String filename, Uint8List? data) {} + static void downloadBinaryFile(String filename, Uint8List data) {} static void reloadBrowser() {}