Web fixes

This commit is contained in:
Hillel Coren 2023-10-17 13:14:43 +03:00
parent 8aaa4710bc
commit 6be8c56e57
3 changed files with 8 additions and 6 deletions

View File

@ -436,7 +436,9 @@ void handleDocumentAction(
final DocumentEntity? document = final DocumentEntity? document =
store.state.documentState.map[documentIds.first]; store.state.documentState.map[documentIds.first];
if (kIsWeb) { if (kIsWeb) {
WebUtils.downloadBinaryFile(document!.name, document.data); if (document?.data != null) {
WebUtils.downloadBinaryFile(document!.name, document.data!);
}
} else { } else {
final directory = await (isDesktopOS() final directory = await (isDesktopOS()
? getDownloadsDirectory() as FutureOr<file.Directory> ? getDownloadsDirectory() as FutureOr<file.Directory>

View File

@ -53,18 +53,18 @@ class WebUtils {
static void reloadBrowser() => window.location.reload(); static void reloadBrowser() => window.location.reload();
static void registerWebView(String html) { static void registerWebView(String? html) {
// ignore: undefined_prefixed_name // ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory( ui.platformViewRegistry.registerViewFactory(
html, html ?? '',
(int viewId) => IFrameElement() (int viewId) => IFrameElement()
..src = html ..src = html
..style.border = 'none'); ..style.border = 'none');
} }
static void warnChanges(Store<AppState> store) { static void warnChanges(Store<AppState>? store) {
window.onBeforeUnload.listen((Event e) { window.onBeforeUnload.listen((Event e) {
if (store.state.hasChanges()) { if (store!.state.hasChanges()) {
(e as BeforeUnloadEvent).returnValue = (e as BeforeUnloadEvent).returnValue =
'Changes you made may not be saved.'; 'Changes you made may not be saved.';
} }

View File

@ -18,7 +18,7 @@ class WebUtils {
static void downloadTextFile(String filename, String data) {} static void downloadTextFile(String filename, String data) {}
static void downloadBinaryFile(String filename, Uint8List? data) {} static void downloadBinaryFile(String filename, Uint8List data) {}
static void reloadBrowser() {} static void reloadBrowser() {}