fix: sync deps doesn't support on web (#1181)
This commit is contained in:
parent
d9a4a73a26
commit
879305dead
8 changed files with 34 additions and 9 deletions
1
example/.gitignore
vendored
1
example/.gitignore
vendored
|
|
@ -35,7 +35,6 @@ migrate_working_dir/
|
||||||
/build/
|
/build/
|
||||||
|
|
||||||
# Web related
|
# Web related
|
||||||
lib/generated_plugin_registrant.dart
|
|
||||||
|
|
||||||
# Symbolication related
|
# Symbolication related
|
||||||
app.*.symbols
|
app.*.symbols
|
||||||
|
|
|
||||||
18
example/lib/file_io_stub.dart
Normal file
18
example/lib/file_io_stub.dart
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Stub file for web - provides empty File class
|
||||||
|
// This file is used when building for web to avoid dart:io dependency
|
||||||
|
|
||||||
|
class File {
|
||||||
|
File(String path);
|
||||||
|
|
||||||
|
Future<void> writeAsString(String contents) async {
|
||||||
|
throw UnsupportedError('File operations are not supported on web');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> writeAsBytes(List<int> bytes) async {
|
||||||
|
throw UnsupportedError('File operations are not supported on web');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> readAsString() async {
|
||||||
|
throw UnsupportedError('File operations are not supported on web');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io' if (dart.library.html) 'package:example/file_io_stub.dart';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
|
|
@ -416,7 +416,7 @@ class _HomePageState extends State<HomePage> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// for desktop
|
// for desktop
|
||||||
final path = await FilePicker.platform.saveFile(
|
final path = await FilePicker.saveFile(
|
||||||
fileName: 'document.${fileType.extension}',
|
fileName: 'document.${fileType.extension}',
|
||||||
);
|
);
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
|
|
@ -444,7 +444,7 @@ class _HomePageState extends State<HomePage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _importFile(ExportFileType fileType) async {
|
void _importFile(ExportFileType fileType) async {
|
||||||
final result = await FilePicker.platform.pickFiles(
|
final result = await FilePicker.pickFiles(
|
||||||
allowMultiple: false,
|
allowMultiple: false,
|
||||||
allowedExtensions: [fileType.extension],
|
allowedExtensions: [fileType.extension],
|
||||||
type: FileType.custom,
|
type: FileType.custom,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
import 'package:appflowy_editor_sync_plugin/appflowy_editor_sync_utility_functions.dart';
|
import 'package:appflowy_editor_sync_plugin/appflowy_editor_sync_utility_functions.dart'
|
||||||
|
if (dart.library.html) 'package:example/sync_plugin_stub.dart';
|
||||||
import 'package:example/home_page.dart';
|
import 'package:example/home_page.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,7 @@ class _DesktopEditorState extends State<DesktopEditor> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add a hover menu to the linked text.
|
// Add a hover menu to the linked text.
|
||||||
if (rects.isNotEmpty && textInsert.attributes?.href != null) {
|
if (rects.isNotEmpty && textInsert.attributes?.href != null) {
|
||||||
widgets.add(
|
widgets.add(
|
||||||
|
|
|
||||||
6
example/lib/sync_plugin_stub.dart
Normal file
6
example/lib/sync_plugin_stub.dart
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
// Stub file for web - provides empty implementation
|
||||||
|
class AppflowyEditorSyncUtilityFunctions {
|
||||||
|
static Future<void> initAppFlowyEditorSync() async {
|
||||||
|
// No-op on web
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ dependencies:
|
||||||
google_fonts: ^6.1.0
|
google_fonts: ^6.1.0
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
file_picker: ^10.2.0
|
file_picker: ^10.3.0
|
||||||
universal_html: ^2.0.8
|
universal_html: ^2.0.8
|
||||||
highlight: ^0.7.0
|
highlight: ^0.7.0
|
||||||
http: ^1.1.0
|
http: ^1.1.0
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import 'package:file_picker/file_picker.dart' as fp;
|
||||||
class FilePicker implements FilePickerService {
|
class FilePicker implements FilePickerService {
|
||||||
@override
|
@override
|
||||||
Future<String?> getDirectoryPath({String? title}) {
|
Future<String?> getDirectoryPath({String? title}) {
|
||||||
return fp.FilePicker.platform.getDirectoryPath();
|
return fp.FilePicker.getDirectoryPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -19,7 +19,7 @@ class FilePicker implements FilePickerService {
|
||||||
bool withReadStream = false,
|
bool withReadStream = false,
|
||||||
bool lockParentWindow = false,
|
bool lockParentWindow = false,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await fp.FilePicker.platform.pickFiles(
|
final result = await fp.FilePicker.pickFiles(
|
||||||
dialogTitle: dialogTitle,
|
dialogTitle: dialogTitle,
|
||||||
initialDirectory: initialDirectory,
|
initialDirectory: initialDirectory,
|
||||||
type: type,
|
type: type,
|
||||||
|
|
@ -43,7 +43,7 @@ class FilePicker implements FilePickerService {
|
||||||
List<String>? allowedExtensions,
|
List<String>? allowedExtensions,
|
||||||
bool lockParentWindow = false,
|
bool lockParentWindow = false,
|
||||||
}) {
|
}) {
|
||||||
return fp.FilePicker.platform.saveFile(
|
return fp.FilePicker.saveFile(
|
||||||
dialogTitle: dialogTitle,
|
dialogTitle: dialogTitle,
|
||||||
fileName: fileName,
|
fileName: fileName,
|
||||||
initialDirectory: initialDirectory,
|
initialDirectory: initialDirectory,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue