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 =
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<file.Directory>

View File

@ -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<AppState> store) {
static void warnChanges(Store<AppState>? 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.';
}

View File

@ -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() {}