浏览代码

updating quick start

Anatoly Pulyaevskiy 4 年前
父节点
当前提交
f3e0d2def4
共有 2 个文件被更改,包括 19 次插入15 次删除
  1. 3
    0
      doc/images.md
  2. 16
    15
      doc/quick-start.md

+ 3
- 0
doc/images.md 查看文件

@@ -166,3 +166,6 @@ class MyAppPageState extends State<MyAppPage> {
166 166
   }
167 167
 }
168 168
 ```
169
+
170
+When `imageDelegate` field is set to non-null value it automatically enables
171
+image selection button in Zefyr's style toolbar.

+ 16
- 15
doc/quick-start.md 查看文件

@@ -20,7 +20,7 @@ $ cd myapp
20 20
 
21 21
 For more methods of creating a project see [official documentation](https://flutter.dev/docs/get-started/test-drive).
22 22
 
23
-### 02. Add Zefyr to your new project
23
+### 02. Add Zefyr to your project
24 24
 
25 25
 Add `zefyr` package as a dependency to `pubspec.yaml` of your new project:
26 26
 
@@ -34,8 +34,8 @@ This installs [zefyr](https://pub.dev/packages/zefyr) and all required
34 34
 dependencies, including [notus](https://pub.dev/packages/notus) package which
35 35
 implements Zefyr's document model.
36 36
 
37
-> Notus package is platform-agnostic and can be used outside of Flutter apps,
38
-> that is, on the web or server-side.
37
+> Notus package is platform-agnostic and can be used outside of Flutter apps
38
+> (in web or server-side Dart projects).
39 39
 
40 40
 ### 03. Create editor page
41 41
 
@@ -68,8 +68,8 @@ class EditorPageState extends State<EditorPage> {
68 68
     super.initState();
69 69
     // Here we must load the document and pass it to Zefyr controller.
70 70
     final document = _loadDocument();
71
-    _controller = new ZefyrController(document);
72
-    _focusNode = new FocusNode();
71
+    _controller = ZefyrController(document);
72
+    _focusNode = FocusNode();
73 73
   }
74 74
 
75 75
   @override
@@ -251,7 +251,7 @@ class EditorPageState extends State<EditorPage> {
251 251
   Future<NotusDocument> _loadDocument() async {
252 252
     final file = File(Directory.systemTemp.path + "/quick_start.json");
253 253
     if (await file.exists()) {
254
-      final contents = file.readAsStringSync();
254
+      final contents = await file.readAsString();
255 255
       return NotusDocument.fromJson(jsonDecode(contents));
256 256
     }
257 257
     final Delta delta = Delta()..insert("Zefyr Quick Start\n");
@@ -265,7 +265,7 @@ are asynchronous. This breaks our `initState` logic so we need to fix it next.
265 265
 However we can no longer initialize `ZefyrController` in `initState` and
266 266
 therefore can't display the editor until document is loaded.
267 267
 
268
-A common way to fix this is to show loader animation while we are reading our
268
+One way to fix this is to show loader animation while we are reading our
269 269
 document from file. But first, we still need to update `initState` method:
270 270
 
271 271
 ```dart
@@ -276,19 +276,19 @@ class EditorPageState extends State<EditorPage> {
276 276
   @override
277 277
   void initState() {
278 278
     super.initState();
279
-    _focusNode = new FocusNode();
279
+    _focusNode = FocusNode();
280 280
     _loadDocument().then((document) {
281 281
       setState(() {
282
-        _controller = new ZefyrController(document);
282
+        _controller = ZefyrController(document);
283 283
       });
284 284
     });
285 285
   }
286 286
 }
287 287
 ```
288 288
 
289
-We initialize `_controller` only when our document is fully loaded from file
289
+We initialize `_controller` only when our document is fully loaded from the file
290 290
 system. An important part here is to update `_controller` field inside of
291
-`setState` call as required by Flutter's stateful widgets.
291
+`setState` call as required by Flutter's `StatefulWidget`'s contract.
292 292
 
293 293
 The only thing left is to update `build()` method to show loader animation:
294 294
 
@@ -333,7 +333,8 @@ If we save changes now and reload the app we should see something like this:
333 333
 
334 334
 <img src="https://github.com/memspace/zefyr/raw/gitbook/assets/quick-start-rec-03.gif" width="600">
335 335
 
336
-Note that in your test you'll likely not notice loading animation at all. This
337
-is because reading a tiny file from disk is too fast. For the above recording
338
-we added an artificial delay of 1 second in order to demonstrate loading. We'll
339
-leave this task to you as an exercise.
336
+Note that in your tests you'll likely not notice any loading animation at all.
337
+This is because reading a tiny file from disk is too fast. For the above
338
+recording we added an artificial delay of 1 second in order to demonstrate
339
+loading. If you'd like to replicate this, we'll leave implementation of this
340
+task to you as an exercise.