File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
frontend/app_flowy/packages/appflowy_editor/example/lib Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -52,9 +52,7 @@ class _HomePageState extends State<HomePage> {
5252 void initState () {
5353 super .initState ();
5454
55- _jsonString = Future <String >.value (
56- jsonEncode (EditorState .empty ().document.toJson ()),
57- );
55+ _jsonString = rootBundle.loadString ('assets/example.json' );
5856 _widgetBuilder = (context) => SimpleEditor (
5957 jsonString: _jsonString,
6058 themeData: _themeData,
@@ -259,11 +257,21 @@ class _HomePageState extends State<HomePage> {
259257 allowedExtensions: [fileType.extension ],
260258 type: FileType .custom,
261259 );
262- final path = result? .files.single.path;
263- if (path == null ) {
264- return ;
260+ var plainText = '' ;
261+ if (! kIsWeb) {
262+ final path = result? .files.single.path;
263+ if (path == null ) {
264+ return ;
265+ }
266+ plainText = await File (path).readAsString ();
267+ } else {
268+ final bytes = result? .files.first.bytes;
269+ if (bytes == null ) {
270+ return ;
271+ }
272+ plainText = const Utf8Decoder ().convert (bytes);
265273 }
266- final plainText = await File (path). readAsString ();
274+
267275 var jsonString = '' ;
268276 switch (fileType) {
269277 case ExportFileType .json:
You can’t perform that action at this time.
0 commit comments