浏览代码

Added pedantic to Zefyr and fixed lint warnings

Anatoly Pulyaevskiy 5 年前
父节点
当前提交
31853227b4
共有 44 个文件被更改,包括 188 次插入203 次删除
  1. 1
    19
      packages/zefyr/analysis_options.yaml
  2. 1
    1
      packages/zefyr/example/lib/main.dart
  3. 2
    2
      packages/zefyr/example/lib/src/editor_page.dart
  4. 3
    3
      packages/zefyr/example/lib/src/form.dart
  5. 6
    6
      packages/zefyr/example/lib/src/full_page.dart
  6. 1
    1
      packages/zefyr/example/lib/src/images.dart
  7. 3
    3
      packages/zefyr/example/lib/src/view.dart
  8. 1
    1
      packages/zefyr/lib/src/fast_diff.dart
  9. 5
    3
      packages/zefyr/lib/src/widgets/buttons.dart
  10. 4
    4
      packages/zefyr/lib/src/widgets/controller.dart
  11. 3
    3
      packages/zefyr/lib/src/widgets/cursor_timer.dart
  12. 3
    3
      packages/zefyr/lib/src/widgets/editable_box.dart
  13. 6
    5
      packages/zefyr/lib/src/widgets/editable_text.dart
  14. 3
    3
      packages/zefyr/lib/src/widgets/editor.dart
  15. 1
    1
      packages/zefyr/lib/src/widgets/field.dart
  16. 12
    12
      packages/zefyr/lib/src/widgets/horizontal_rule.dart
  17. 1
    1
      packages/zefyr/lib/src/widgets/image.dart
  18. 1
    1
      packages/zefyr/lib/src/widgets/input.dart
  19. 2
    2
      packages/zefyr/lib/src/widgets/quote.dart
  20. 3
    3
      packages/zefyr/lib/src/widgets/render_context.dart
  21. 7
    7
      packages/zefyr/lib/src/widgets/rich_text.dart
  22. 1
    1
      packages/zefyr/lib/src/widgets/scope.dart
  23. 1
    1
      packages/zefyr/lib/src/widgets/selection.dart
  24. 16
    17
      packages/zefyr/lib/src/widgets/theme.dart
  25. 2
    2
      packages/zefyr/lib/src/widgets/toolbar.dart
  26. 8
    8
      packages/zefyr/lib/src/widgets/view.dart
  27. 1
    0
      packages/zefyr/pubspec.yaml
  28. 3
    3
      packages/zefyr/test/painting/caret_painter_test.dart
  29. 1
    1
      packages/zefyr/test/rendering/render_editable_proxy_box_test.dart
  30. 6
    6
      packages/zefyr/test/rendering/render_zefyr_paragraph_test.dart
  31. 4
    4
      packages/zefyr/test/testing.dart
  32. 6
    6
      packages/zefyr/test/util_test.dart
  33. 12
    12
      packages/zefyr/test/widgets/buttons_test.dart
  34. 1
    1
      packages/zefyr/test/widgets/code_test.dart
  35. 18
    18
      packages/zefyr/test/widgets/controller_test.dart
  36. 5
    5
      packages/zefyr/test/widgets/editable_text_test.dart
  37. 5
    5
      packages/zefyr/test/widgets/editor_test.dart
  38. 5
    5
      packages/zefyr/test/widgets/horizontal_rule_test.dart
  39. 5
    5
      packages/zefyr/test/widgets/image_test.dart
  40. 1
    1
      packages/zefyr/test/widgets/list_test.dart
  41. 1
    1
      packages/zefyr/test/widgets/quote_test.dart
  42. 7
    7
      packages/zefyr/test/widgets/render_context_test.dart
  43. 4
    4
      packages/zefyr/test/widgets/rich_text_test.dart
  44. 6
    6
      packages/zefyr/test/widgets/selection_test.dart

+ 1
- 19
packages/zefyr/analysis_options.yaml 查看文件

1
-analyzer:
2
-  strong-mode:
3
-    implicit-dynamic: false
4
-
5
-# Lint rules and documentation, see http://dart-lang.github.io/linter/lints
6
-linter:
7
-  rules:
8
-    - avoid_init_to_null
9
-    - cancel_subscriptions
10
-    - close_sinks
11
-    - directives_ordering
12
-    - hash_and_equals
13
-    - iterable_contains_unrelated_type
14
-    - list_remove_unrelated_type
15
-    - prefer_final_fields
16
-    - prefer_is_not_empty
17
-    - test_types_in_equals
18
-    - unrelated_type_equality_checks
19
-    - valid_regexps
1
+include: package:pedantic/analysis_options.yaml

+ 1
- 1
packages/zefyr/example/lib/main.dart 查看文件

7
 import 'src/view.dart';
7
 import 'src/view.dart';
8
 
8
 
9
 void main() {
9
 void main() {
10
-  runApp(new ZefyrApp());
10
+  runApp(ZefyrApp());
11
 }
11
 }
12
 
12
 
13
 class ZefyrApp extends StatelessWidget {
13
 class ZefyrApp extends StatelessWidget {

+ 2
- 2
packages/zefyr/example/lib/src/editor_page.dart 查看文件

20
   @override
20
   @override
21
   void initState() {
21
   void initState() {
22
     super.initState();
22
     super.initState();
23
-    _focusNode = new FocusNode();
23
+    _focusNode = FocusNode();
24
     _loadDocument().then((document) {
24
     _loadDocument().then((document) {
25
       setState(() {
25
       setState(() {
26
-        _controller = new ZefyrController(document);
26
+        _controller = ZefyrController(document);
27
       });
27
       });
28
     });
28
     });
29
   }
29
   }

+ 3
- 3
packages/zefyr/example/lib/src/form.dart 查看文件

15
 
15
 
16
 class _FormEmbeddedScreenState extends State<FormEmbeddedScreen> {
16
 class _FormEmbeddedScreenState extends State<FormEmbeddedScreen> {
17
   final ZefyrController _controller = ZefyrController(NotusDocument());
17
   final ZefyrController _controller = ZefyrController(NotusDocument());
18
-  final FocusNode _focusNode = new FocusNode();
18
+  final FocusNode _focusNode = FocusNode();
19
 
19
 
20
   @override
20
   @override
21
   Widget build(BuildContext context) {
21
   Widget build(BuildContext context) {
45
   }
45
   }
46
 
46
 
47
   Widget buildEditor() {
47
   Widget buildEditor() {
48
-    final theme = new ZefyrThemeData(
48
+    final theme = ZefyrThemeData(
49
       toolbarTheme: ZefyrToolbarTheme.fallback(context).copyWith(
49
       toolbarTheme: ZefyrToolbarTheme.fallback(context).copyWith(
50
         color: Colors.grey.shade800,
50
         color: Colors.grey.shade800,
51
         toggleColor: Colors.grey.shade900,
51
         toggleColor: Colors.grey.shade900,
62
         controller: _controller,
62
         controller: _controller,
63
         focusNode: _focusNode,
63
         focusNode: _focusNode,
64
         autofocus: true,
64
         autofocus: true,
65
-        imageDelegate: new CustomImageDelegate(),
65
+        imageDelegate: CustomImageDelegate(),
66
         physics: ClampingScrollPhysics(),
66
         physics: ClampingScrollPhysics(),
67
       ),
67
       ),
68
     );
68
     );

+ 6
- 6
packages/zefyr/example/lib/src/full_page.dart 查看文件

27
 
27
 
28
 class FullPageEditorScreen extends StatefulWidget {
28
 class FullPageEditorScreen extends StatefulWidget {
29
   @override
29
   @override
30
-  _FullPageEditorScreenState createState() => new _FullPageEditorScreenState();
30
+  _FullPageEditorScreenState createState() => _FullPageEditorScreenState();
31
 }
31
 }
32
 
32
 
33
 final doc =
33
 final doc =
44
 class _FullPageEditorScreenState extends State<FullPageEditorScreen> {
44
 class _FullPageEditorScreenState extends State<FullPageEditorScreen> {
45
   final ZefyrController _controller =
45
   final ZefyrController _controller =
46
       ZefyrController(NotusDocument.fromDelta(getDelta()));
46
       ZefyrController(NotusDocument.fromDelta(getDelta()));
47
-  final FocusNode _focusNode = new FocusNode();
47
+  final FocusNode _focusNode = FocusNode();
48
   bool _editing = false;
48
   bool _editing = false;
49
   StreamSubscription<NotusChange> _sub;
49
   StreamSubscription<NotusChange> _sub;
50
 
50
 
64
 
64
 
65
   @override
65
   @override
66
   Widget build(BuildContext context) {
66
   Widget build(BuildContext context) {
67
-    final theme = new ZefyrThemeData(
67
+    final theme = ZefyrThemeData(
68
       cursorColor: Colors.blue,
68
       cursorColor: Colors.blue,
69
       toolbarTheme: ZefyrToolbarTheme.fallback(context).copyWith(
69
       toolbarTheme: ZefyrToolbarTheme.fallback(context).copyWith(
70
         color: Colors.grey.shade800,
70
         color: Colors.grey.shade800,
75
     );
75
     );
76
 
76
 
77
     final done = _editing
77
     final done = _editing
78
-        ? [new FlatButton(onPressed: _stopEditing, child: Text('DONE'))]
79
-        : [new FlatButton(onPressed: _startEditing, child: Text('EDIT'))];
78
+        ? [FlatButton(onPressed: _stopEditing, child: Text('DONE'))]
79
+        : [FlatButton(onPressed: _startEditing, child: Text('EDIT'))];
80
     return Scaffold(
80
     return Scaffold(
81
       resizeToAvoidBottomPadding: true,
81
       resizeToAvoidBottomPadding: true,
82
       appBar: AppBar(
82
       appBar: AppBar(
93
             controller: _controller,
93
             controller: _controller,
94
             focusNode: _focusNode,
94
             focusNode: _focusNode,
95
             mode: _editing ? ZefyrMode.edit : ZefyrMode.select,
95
             mode: _editing ? ZefyrMode.edit : ZefyrMode.select,
96
-            imageDelegate: new CustomImageDelegate(),
96
+            imageDelegate: CustomImageDelegate(),
97
           ),
97
           ),
98
         ),
98
         ),
99
       ),
99
       ),

+ 1
- 1
packages/zefyr/example/lib/src/images.dart 查看文件

34
       // Otherwise assume this is a file stored locally on user's device.
34
       // Otherwise assume this is a file stored locally on user's device.
35
       final file = File.fromUri(Uri.parse(key));
35
       final file = File.fromUri(Uri.parse(key));
36
       final image = FileImage(file);
36
       final image = FileImage(file);
37
-      return new Image(image: image);
37
+      return Image(image: image);
38
     }
38
     }
39
   }
39
   }
40
 }
40
 }

+ 3
- 3
packages/zefyr/example/lib/src/view.dart 查看文件

13
 
13
 
14
 class ViewScreen extends StatefulWidget {
14
 class ViewScreen extends StatefulWidget {
15
   @override
15
   @override
16
-  _ViewScreen createState() => new _ViewScreen();
16
+  _ViewScreen createState() => _ViewScreen();
17
 }
17
 }
18
 
18
 
19
 final doc =
19
 final doc =
32
 
32
 
33
   @override
33
   @override
34
   Widget build(BuildContext context) {
34
   Widget build(BuildContext context) {
35
-    final theme = new ZefyrThemeData(
35
+    final theme = ZefyrThemeData(
36
       toolbarTheme: ZefyrToolbarTheme.fallback(context).copyWith(
36
       toolbarTheme: ZefyrToolbarTheme.fallback(context).copyWith(
37
         color: Colors.grey.shade800,
37
         color: Colors.grey.shade800,
38
         toggleColor: Colors.grey.shade900,
38
         toggleColor: Colors.grey.shade900,
64
               padding: const EdgeInsets.all(16.0),
64
               padding: const EdgeInsets.all(16.0),
65
               child: ZefyrView(
65
               child: ZefyrView(
66
                 document: doc,
66
                 document: doc,
67
-                imageDelegate: new CustomImageDelegate(),
67
+                imageDelegate: CustomImageDelegate(),
68
               ),
68
               ),
69
             )
69
             )
70
           ],
70
           ],

+ 1
- 1
packages/zefyr/lib/src/fast_diff.dart 查看文件

19
   }
19
   }
20
   final String deleted = (start < end) ? oldText.substring(start, end) : '';
20
   final String deleted = (start < end) ? oldText.substring(start, end) : '';
21
   final inserted = newText.substring(start, end + delta);
21
   final inserted = newText.substring(start, end + delta);
22
-  return new DiffResult(start, deleted, inserted);
22
+  return DiffResult(start, deleted, inserted);
23
 }
23
 }
24
 
24
 
25
 /// A diff between two strings of text.
25
 /// A diff between two strings of text.

+ 5
- 3
packages/zefyr/lib/src/widgets/buttons.dart 查看文件

280
     final editor = ZefyrToolbar.of(context).editor;
280
     final editor = ZefyrToolbar.of(context).editor;
281
     final image =
281
     final image =
282
         await editor.imageDelegate.pickImage(editor.imageDelegate.cameraSource);
282
         await editor.imageDelegate.pickImage(editor.imageDelegate.cameraSource);
283
-    if (image != null)
283
+    if (image != null) {
284
       editor.formatSelection(NotusAttribute.embed.image(image));
284
       editor.formatSelection(NotusAttribute.embed.image(image));
285
+    }
285
   }
286
   }
286
 
287
 
287
   void _pickFromGallery() async {
288
   void _pickFromGallery() async {
288
     final editor = ZefyrToolbar.of(context).editor;
289
     final editor = ZefyrToolbar.of(context).editor;
289
     final image = await editor.imageDelegate
290
     final image = await editor.imageDelegate
290
         .pickImage(editor.imageDelegate.gallerySource);
291
         .pickImage(editor.imageDelegate.gallerySource);
291
-    if (image != null)
292
+    if (image != null) {
292
       editor.formatSelection(NotusAttribute.embed.image(image));
293
       editor.formatSelection(NotusAttribute.embed.image(image));
294
+    }
293
   }
295
   }
294
 }
296
 }
295
 
297
 
480
   final bool formatError;
482
   final bool formatError;
481
 
483
 
482
   const _LinkInput(
484
   const _LinkInput(
483
-      {Key key, @required this.controller, this.formatError: false})
485
+      {Key key, @required this.controller, this.formatError = false})
484
       : super(key: key);
486
       : super(key: key);
485
 
487
 
486
   @override
488
   @override

+ 4
- 4
packages/zefyr/lib/src/widgets/controller.dart 查看文件

8
 import 'package:quill_delta/quill_delta.dart';
8
 import 'package:quill_delta/quill_delta.dart';
9
 import 'package:zefyr/util.dart';
9
 import 'package:zefyr/util.dart';
10
 
10
 
11
-const TextSelection _kZeroSelection = const TextSelection.collapsed(
11
+const TextSelection _kZeroSelection = TextSelection.collapsed(
12
   offset: 0,
12
   offset: 0,
13
   affinity: TextAffinity.upstream,
13
   affinity: TextAffinity.upstream,
14
 );
14
 );
48
   ///
48
   ///
49
   /// [value] and [source] cannot be `null`.
49
   /// [value] and [source] cannot be `null`.
50
   void updateSelection(TextSelection value,
50
   void updateSelection(TextSelection value,
51
-      {ChangeSource source: ChangeSource.remote}) {
51
+      {ChangeSource source = ChangeSource.remote}) {
52
     _updateSelectionSilent(value, source: source);
52
     _updateSelectionSilent(value, source: source);
53
     notifyListeners();
53
     notifyListeners();
54
   }
54
   }
55
 
55
 
56
   // Updates selection without triggering notifications to listeners.
56
   // Updates selection without triggering notifications to listeners.
57
   void _updateSelectionSilent(TextSelection value,
57
   void _updateSelectionSilent(TextSelection value,
58
-      {ChangeSource source: ChangeSource.remote}) {
58
+      {ChangeSource source = ChangeSource.remote}) {
59
     assert(value != null && source != null);
59
     assert(value != null && source != null);
60
     _selection = value;
60
     _selection = value;
61
     _lastChangeSource = source;
61
     _lastChangeSource = source;
76
   ///
76
   ///
77
   /// If composing this change fails then this method throws [ComposeError].
77
   /// If composing this change fails then this method throws [ComposeError].
78
   void compose(Delta change,
78
   void compose(Delta change,
79
-      {TextSelection selection, ChangeSource source: ChangeSource.remote}) {
79
+      {TextSelection selection, ChangeSource source = ChangeSource.remote}) {
80
     if (change.isNotEmpty) {
80
     if (change.isNotEmpty) {
81
       _document.compose(change, source);
81
       _document.compose(change, source);
82
     }
82
     }

+ 3
- 3
packages/zefyr/lib/src/widgets/cursor_timer.dart 查看文件

4
 
4
 
5
 /// Helper class that keeps state relevant to the editing cursor.
5
 /// Helper class that keeps state relevant to the editing cursor.
6
 class CursorTimer {
6
 class CursorTimer {
7
-  static const _kCursorBlinkHalfPeriod = const Duration(milliseconds: 500);
7
+  static const _kCursorBlinkHalfPeriod = Duration(milliseconds: 500);
8
 
8
 
9
   Timer _timer;
9
   Timer _timer;
10
-  final ValueNotifier<bool> _showCursor = new ValueNotifier<bool>(false);
10
+  final ValueNotifier<bool> _showCursor = ValueNotifier<bool>(false);
11
 
11
 
12
   ValueNotifier<bool> get value => _showCursor;
12
   ValueNotifier<bool> get value => _showCursor;
13
 
13
 
18
   /// Starts cursor timer.
18
   /// Starts cursor timer.
19
   void start() {
19
   void start() {
20
     _showCursor.value = true;
20
     _showCursor.value = true;
21
-    _timer = new Timer.periodic(_kCursorBlinkHalfPeriod, _cursorTick);
21
+    _timer = Timer.periodic(_kCursorBlinkHalfPeriod, _cursorTick);
22
   }
22
   }
23
 
23
 
24
   /// Stops cursor timer.
24
   /// Stops cursor timer.

+ 3
- 3
packages/zefyr/lib/src/widgets/editable_box.dart 查看文件

96
 
96
 
97
   ContainerNode get node => _node;
97
   ContainerNode get node => _node;
98
   ContainerNode _node;
98
   ContainerNode _node;
99
-  void set node(ContainerNode value) {
99
+  set node(ContainerNode value) {
100
     _node = value;
100
     _node = value;
101
   }
101
   }
102
 
102
 
103
   LayerLink get layerLink => _layerLink;
103
   LayerLink get layerLink => _layerLink;
104
   LayerLink _layerLink;
104
   LayerLink _layerLink;
105
-  void set layerLink(LayerLink value) {
105
+  set layerLink(LayerLink value) {
106
     if (_layerLink == value) return;
106
     if (_layerLink == value) return;
107
     _layerLink = value;
107
     _layerLink = value;
108
   }
108
   }
109
 
109
 
110
   ZefyrRenderContext _renderContext;
110
   ZefyrRenderContext _renderContext;
111
-  void set renderContext(ZefyrRenderContext value) {
111
+  set renderContext(ZefyrRenderContext value) {
112
     if (_renderContext == value) return;
112
     if (_renderContext == value) return;
113
     if (attached) _renderContext.removeBox(this);
113
     if (attached) _renderContext.removeBox(this);
114
     _renderContext = value;
114
     _renderContext = value;

+ 6
- 5
packages/zefyr/lib/src/widgets/editable_text.dart 查看文件

36
     @required this.focusNode,
36
     @required this.focusNode,
37
     @required this.imageDelegate,
37
     @required this.imageDelegate,
38
     this.selectionControls,
38
     this.selectionControls,
39
-    this.autofocus: true,
40
-    this.mode: ZefyrMode.edit,
41
-    this.padding: const EdgeInsets.symmetric(horizontal: 16.0),
39
+    this.autofocus = true,
40
+    this.mode = ZefyrMode.edit,
41
+    this.padding = const EdgeInsets.symmetric(horizontal: 16.0),
42
     this.physics,
42
     this.physics,
43
   })  : assert(mode != null),
43
   })  : assert(mode != null),
44
         assert(controller != null),
44
         assert(controller != null),
102
   /// focus, the control will then attach to the keyboard and request that the
102
   /// focus, the control will then attach to the keyboard and request that the
103
   /// keyboard become visible.
103
   /// keyboard become visible.
104
   void requestKeyboard() {
104
   void requestKeyboard() {
105
-    if (_focusNode.hasFocus)
105
+    if (_focusNode.hasFocus) {
106
       _input.openConnection(widget.controller.plainTextEditingValue);
106
       _input.openConnection(widget.controller.plainTextEditingValue);
107
-    else
107
+    } else {
108
       FocusScope.of(context).requestFocus(_focusNode);
108
       FocusScope.of(context).requestFocus(_focusNode);
109
+    }
109
   }
110
   }
110
 
111
 
111
   void focusOrUnfocusIfNeeded() {
112
   void focusOrUnfocusIfNeeded() {

+ 3
- 3
packages/zefyr/lib/src/widgets/editor.dart 查看文件

20
     Key key,
20
     Key key,
21
     @required this.controller,
21
     @required this.controller,
22
     @required this.focusNode,
22
     @required this.focusNode,
23
-    this.autofocus: true,
24
-    this.mode: ZefyrMode.edit,
25
-    this.padding: const EdgeInsets.symmetric(horizontal: 16.0),
23
+    this.autofocus = true,
24
+    this.mode = ZefyrMode.edit,
25
+    this.padding = const EdgeInsets.symmetric(horizontal: 16.0),
26
     this.toolbarDelegate,
26
     this.toolbarDelegate,
27
     this.imageDelegate,
27
     this.imageDelegate,
28
     this.selectionControls,
28
     this.selectionControls,

+ 1
- 1
packages/zefyr/lib/src/widgets/field.dart 查看文件

27
     this.height,
27
     this.height,
28
     this.controller,
28
     this.controller,
29
     this.focusNode,
29
     this.focusNode,
30
-    this.autofocus: false,
30
+    this.autofocus = false,
31
     this.mode,
31
     this.mode,
32
     this.toolbarDelegate,
32
     this.toolbarDelegate,
33
     this.imageDelegate,
33
     this.imageDelegate,

+ 12
- 12
packages/zefyr/lib/src/widgets/horizontal_rule.dart 查看文件

17
 
17
 
18
   @override
18
   @override
19
   RenderHorizontalRule createRenderObject(BuildContext context) {
19
   RenderHorizontalRule createRenderObject(BuildContext context) {
20
-    return new RenderHorizontalRule(node: node);
20
+    return RenderHorizontalRule(node: node);
21
   }
21
   }
22
 
22
 
23
   @override
23
   @override
57
     if (local.isCollapsed) {
57
     if (local.isCollapsed) {
58
       final dx = local.extentOffset == 0 ? 0.0 : size.width;
58
       final dx = local.extentOffset == 0 ? 0.0 : size.width;
59
       return [
59
       return [
60
-        new ui.TextBox.fromLTRBD(dx, 0.0, dx, size.height, TextDirection.ltr),
60
+        ui.TextBox.fromLTRBD(dx, 0.0, dx, size.height, TextDirection.ltr),
61
       ];
61
       ];
62
     }
62
     }
63
 
63
 
64
     return [
64
     return [
65
-      new ui.TextBox.fromLTRBD(0.0, 0.0, 0.0, size.height, TextDirection.ltr),
66
-      new ui.TextBox.fromLTRBD(
65
+      ui.TextBox.fromLTRBD(0.0, 0.0, 0.0, size.height, TextDirection.ltr),
66
+      ui.TextBox.fromLTRBD(
67
           size.width, 0.0, size.width, size.height, TextDirection.ltr),
67
           size.width, 0.0, size.width, size.height, TextDirection.ltr),
68
     ];
68
     ];
69
   }
69
   }
71
   @override
71
   @override
72
   void performLayout() {
72
   void performLayout() {
73
     assert(constraints.hasBoundedWidth);
73
     assert(constraints.hasBoundedWidth);
74
-    size = new Size(constraints.maxWidth, _kHeight);
74
+    size = Size(constraints.maxWidth, _kHeight);
75
   }
75
   }
76
 
76
 
77
   @override
77
   @override
78
   void paint(PaintingContext context, Offset offset) {
78
   void paint(PaintingContext context, Offset offset) {
79
-    final rect = new Rect.fromLTWH(0.0, 0.0, size.width, _kThickness);
80
-    final paint = new ui.Paint()..color = Colors.grey.shade200;
79
+    final rect = Rect.fromLTWH(0.0, 0.0, size.width, _kThickness);
80
+    final paint = ui.Paint()..color = Colors.grey.shade200;
81
     context.canvas.drawRect(rect.shift(offset), paint);
81
     context.canvas.drawRect(rect.shift(offset), paint);
82
   }
82
   }
83
 
83
 
88
     if (offset.dx > size.width / 2) {
88
     if (offset.dx > size.width / 2) {
89
       position++;
89
       position++;
90
     }
90
     }
91
-    return new TextPosition(offset: position);
91
+    return TextPosition(offset: position);
92
   }
92
   }
93
 
93
 
94
   @override
94
   @override
95
   TextRange getWordBoundary(TextPosition position) {
95
   TextRange getWordBoundary(TextPosition position) {
96
     final start = _node.documentOffset;
96
     final start = _node.documentOffset;
97
-    return new TextRange(start: start, end: start + 1);
97
+    return TextRange(start: start, end: start + 1);
98
   }
98
   }
99
 
99
 
100
   @override
100
   @override
103
     final localSelection = getLocalSelection(selection);
103
     final localSelection = getLocalSelection(selection);
104
     assert(localSelection != null);
104
     assert(localSelection != null);
105
     if (!localSelection.isCollapsed) {
105
     if (!localSelection.isCollapsed) {
106
-      final Paint paint = new Paint()..color = selectionColor;
107
-      final rect = new Rect.fromLTWH(0.0, 0.0, size.width, _kHeight);
106
+      final Paint paint = Paint()..color = selectionColor;
107
+      final rect = Rect.fromLTWH(0.0, 0.0, size.width, _kHeight);
108
       context.canvas.drawRect(rect.shift(offset), paint);
108
       context.canvas.drawRect(rect.shift(offset), paint);
109
     }
109
     }
110
   }
110
   }
114
     final pos = position.offset - node.documentOffset;
114
     final pos = position.offset - node.documentOffset;
115
     Offset caretOffset = Offset.zero;
115
     Offset caretOffset = Offset.zero;
116
     if (pos == 1) {
116
     if (pos == 1) {
117
-      caretOffset = caretOffset + new Offset(size.width - 1.0, 0.0);
117
+      caretOffset = caretOffset + Offset(size.width - 1.0, 0.0);
118
     }
118
     }
119
     return caretOffset;
119
     return caretOffset;
120
   }
120
   }

+ 1
- 1
packages/zefyr/lib/src/widgets/image.dart 查看文件

100
   @override
100
   @override
101
   EmbedNode get node => _node;
101
   EmbedNode get node => _node;
102
   EmbedNode _node;
102
   EmbedNode _node;
103
-  void set node(EmbedNode value) {
103
+  set node(EmbedNode value) {
104
     _node = value;
104
     _node = value;
105
   }
105
   }
106
 
106
 

+ 1
- 1
packages/zefyr/lib/src/widgets/input.dart 查看文件

13
       : assert(onValueChanged != null);
13
       : assert(onValueChanged != null);
14
 
14
 
15
   //
15
   //
16
-  // New public members
16
+  // public members
17
   //
17
   //
18
 
18
 
19
   final RemoteValueChanged onValueChanged;
19
   final RemoteValueChanged onValueChanged;

+ 2
- 2
packages/zefyr/lib/src/widgets/quote.dart 查看文件

36
 
36
 
37
     Widget content;
37
     Widget content;
38
     if (line.style.contains(NotusAttribute.heading)) {
38
     if (line.style.contains(NotusAttribute.heading)) {
39
-      content = new ZefyrHeading(node: line, blockStyle: blockStyle);
39
+      content = ZefyrHeading(node: line, blockStyle: blockStyle);
40
     } else {
40
     } else {
41
-      content = new ZefyrParagraph(node: line, blockStyle: blockStyle);
41
+      content = ZefyrParagraph(node: line, blockStyle: blockStyle);
42
     }
42
     }
43
 
43
 
44
     final row = Row(children: <Widget>[Expanded(child: content)]);
44
     final row = Row(children: <Widget>[Expanded(child: content)]);

+ 3
- 3
packages/zefyr/lib/src/widgets/render_context.dart 查看文件

35
 /// When a box is detached from rendering pipeline it unregisters
35
 /// When a box is detached from rendering pipeline it unregisters
36
 /// itself by calling [removeBox].
36
 /// itself by calling [removeBox].
37
 class ZefyrRenderContext extends ChangeNotifier {
37
 class ZefyrRenderContext extends ChangeNotifier {
38
-  final Set<RenderEditableProxyBox> _dirtyBoxes = new Set();
39
-  final Set<RenderEditableProxyBox> _activeBoxes = new Set();
38
+  final Set<RenderEditableProxyBox> _dirtyBoxes = Set();
39
+  final Set<RenderEditableProxyBox> _activeBoxes = Set();
40
 
40
 
41
   Set<RenderEditableProxyBox> get dirty => _dirtyBoxes;
41
   Set<RenderEditableProxyBox> get dirty => _dirtyBoxes;
42
   Set<RenderEditableProxyBox> get active => _activeBoxes;
42
   Set<RenderEditableProxyBox> get active => _activeBoxes;
116
     box = _activeBoxes.map((p) {
116
     box = _activeBoxes.map((p) {
117
       final localPoint = p.globalToLocal(point);
117
       final localPoint = p.globalToLocal(point);
118
       final distance = localPoint.dy - p.size.height;
118
       final distance = localPoint.dy - p.size.height;
119
-      return new MapEntry(distance.abs(), p);
119
+      return MapEntry(distance.abs(), p);
120
     }).reduce((a, b) {
120
     }).reduce((a, b) {
121
       return (a.key <= b.key) ? a : b;
121
       return (a.key <= b.key) ? a : b;
122
     }).value;
122
     }).value;

+ 7
- 7
packages/zefyr/lib/src/widgets/rich_text.dart 查看文件

44
   RenderZefyrParagraph(
44
   RenderZefyrParagraph(
45
     TextSpan text, {
45
     TextSpan text, {
46
     @required LineNode node,
46
     @required LineNode node,
47
-    TextAlign textAlign: TextAlign.start,
47
+    TextAlign textAlign = TextAlign.start,
48
     @required TextDirection textDirection,
48
     @required TextDirection textDirection,
49
-    bool softWrap: true,
50
-    TextOverflow overflow: TextOverflow.clip,
51
-    double textScaleFactor: 1.0,
49
+    bool softWrap = true,
50
+    TextOverflow overflow = TextOverflow.clip,
51
+    double textScaleFactor = 1.0,
52
     int maxLines,
52
     int maxLines,
53
   })  : _node = node,
53
   })  : _node = node,
54
         _prototypePainter = TextPainter(
54
         _prototypePainter = TextPainter(
69
 
69
 
70
   LineNode get node => _node;
70
   LineNode get node => _node;
71
   LineNode _node;
71
   LineNode _node;
72
-  void set node(LineNode value) {
72
+  set node(LineNode value) {
73
     _node = value;
73
     _node = value;
74
   }
74
   }
75
 
75
 
181
   //
181
   //
182
 
182
 
183
   @override
183
   @override
184
-  void set text(InlineSpan value) {
184
+  set text(InlineSpan value) {
185
     _prototypePainter.text = TextSpan(text: '.', style: value.style);
185
     _prototypePainter.text = TextSpan(text: '.', style: value.style);
186
     _selectionRects = null;
186
     _selectionRects = null;
187
     super.text = value;
187
     super.text = value;
218
       _selectionRects = null;
218
       _selectionRects = null;
219
     }
219
     }
220
     _selectionRects ??= getBoxesForSelection(getLocalSelection(selection));
220
     _selectionRects ??= getBoxesForSelection(getLocalSelection(selection));
221
-    final Paint paint = new Paint()..color = selectionColor;
221
+    final Paint paint = Paint()..color = selectionColor;
222
     for (ui.TextBox box in _selectionRects) {
222
     for (ui.TextBox box in _selectionRects) {
223
       context.canvas.drawRect(box.toRect().shift(offset), paint);
223
       context.canvas.drawRect(box.toRect().shift(offset), paint);
224
     }
224
     }

+ 1
- 1
packages/zefyr/lib/src/widgets/scope.dart 查看文件

169
   }
169
   }
170
 
170
 
171
   void updateSelection(TextSelection value,
171
   void updateSelection(TextSelection value,
172
-      {ChangeSource source: ChangeSource.remote}) {
172
+      {ChangeSource source = ChangeSource.remote}) {
173
     assert(isEditable);
173
     assert(isEditable);
174
     assert(!_disposed);
174
     assert(!_disposed);
175
     _controller.updateSelection(value, source: source);
175
     _controller.updateSelection(value, source: source);

+ 1
- 1
packages/zefyr/lib/src/widgets/selection.dart 查看文件

109
     _toolbarController?.stop();
109
     _toolbarController?.stop();
110
   }
110
   }
111
 
111
 
112
-  static const Duration _kFadeDuration = const Duration(milliseconds: 150);
112
+  static const Duration _kFadeDuration = Duration(milliseconds: 150);
113
 
113
 
114
   @override
114
   @override
115
   void initState() {
115
   void initState() {

+ 16
- 17
packages/zefyr/lib/src/widgets/theme.dart 查看文件

41
   /// Returns `null` if there is no [ZefyrTheme] in the given build context
41
   /// Returns `null` if there is no [ZefyrTheme] in the given build context
42
   /// and [nullOk] is set to `true`. If [nullOk] is set to `false` (default)
42
   /// and [nullOk] is set to `true`. If [nullOk] is set to `false` (default)
43
   /// then this method asserts.
43
   /// then this method asserts.
44
-  static ZefyrThemeData of(BuildContext context, {bool nullOk: false}) {
44
+  static ZefyrThemeData of(BuildContext context, {bool nullOk = false}) {
45
     final ZefyrTheme widget = context.inheritFromWidgetOfExactType(ZefyrTheme);
45
     final ZefyrTheme widget = context.inheritFromWidgetOfExactType(ZefyrTheme);
46
     if (widget == null && nullOk) return null;
46
     if (widget == null && nullOk) return null;
47
     assert(widget != null,
47
     assert(widget != null,
75
       color: Colors.grey.shade800,
75
       color: Colors.grey.shade800,
76
     );
76
     );
77
     final padding = const EdgeInsets.only(bottom: 16.0);
77
     final padding = const EdgeInsets.only(bottom: 16.0);
78
-    final boldStyle = new TextStyle(fontWeight: FontWeight.bold);
79
-    final italicStyle = new TextStyle(fontStyle: FontStyle.italic);
78
+    final boldStyle = TextStyle(fontWeight: FontWeight.bold);
79
+    final italicStyle = TextStyle(fontStyle: FontStyle.italic);
80
     final linkStyle =
80
     final linkStyle =
81
         TextStyle(color: Colors.blue, decoration: TextDecoration.underline);
81
         TextStyle(color: Colors.blue, decoration: TextDecoration.underline);
82
 
82
 
83
-    return new ZefyrThemeData(
83
+    return ZefyrThemeData(
84
       boldStyle: boldStyle,
84
       boldStyle: boldStyle,
85
       italicStyle: italicStyle,
85
       italicStyle: italicStyle,
86
       linkStyle: linkStyle,
86
       linkStyle: linkStyle,
87
-      paragraphTheme:
88
-          new StyleTheme(textStyle: paragraphStyle, padding: padding),
89
-      headingTheme: new HeadingTheme.fallback(),
90
-      blockTheme: new BlockTheme.fallback(themeData),
87
+      paragraphTheme: StyleTheme(textStyle: paragraphStyle, padding: padding),
88
+      headingTheme: HeadingTheme.fallback(),
89
+      blockTheme: BlockTheme.fallback(themeData),
91
       selectionColor: Colors.lightBlueAccent.shade100,
90
       selectionColor: Colors.lightBlueAccent.shade100,
92
       cursorColor: Colors.black,
91
       cursorColor: Colors.black,
93
       indentSize: 16.0,
92
       indentSize: 16.0,
94
-      toolbarTheme: new ZefyrToolbarTheme.fallback(context),
93
+      toolbarTheme: ZefyrToolbarTheme.fallback(context),
95
     );
94
     );
96
   }
95
   }
97
 
96
 
121
     double indentSize,
120
     double indentSize,
122
     ZefyrToolbarTheme toolbarTheme,
121
     ZefyrToolbarTheme toolbarTheme,
123
   }) {
122
   }) {
124
-    return new ZefyrThemeData(
123
+    return ZefyrThemeData(
125
       boldStyle: boldStyle ?? this.boldStyle,
124
       boldStyle: boldStyle ?? this.boldStyle,
126
       italicStyle: italicStyle ?? this.italicStyle,
125
       italicStyle: italicStyle ?? this.italicStyle,
127
       linkStyle: linkStyle ?? this.linkStyle,
126
       linkStyle: linkStyle ?? this.linkStyle,
237
         break;
236
         break;
238
     }
237
     }
239
 
238
 
240
-    return new BlockTheme(
241
-      bulletList: new StyleTheme(padding: padding),
242
-      numberList: new StyleTheme(padding: padding),
243
-      quote: new StyleTheme(
244
-        textStyle: new TextStyle(color: Colors.grey.shade700),
239
+    return BlockTheme(
240
+      bulletList: StyleTheme(padding: padding),
241
+      numberList: StyleTheme(padding: padding),
242
+      quote: StyleTheme(
243
+        textStyle: TextStyle(color: Colors.grey.shade700),
245
         padding: padding,
244
         padding: padding,
246
       ),
245
       ),
247
-      code: new StyleTheme(
248
-        textStyle: new TextStyle(
246
+      code: StyleTheme(
247
+        textStyle: TextStyle(
249
           color: Colors.blueGrey.shade800,
248
           color: Colors.blueGrey.shade800,
250
           fontFamily: fontFamily,
249
           fontFamily: fontFamily,
251
           fontSize: 14.0,
250
           fontSize: 14.0,

+ 2
- 2
packages/zefyr/lib/src/widgets/toolbar.dart 查看文件

66
     Key key,
66
     Key key,
67
     @required this.body,
67
     @required this.body,
68
     this.trailing,
68
     this.trailing,
69
-    this.autoImplyTrailing: true,
69
+    this.autoImplyTrailing = true,
70
   }) : super(key: key);
70
   }) : super(key: key);
71
 
71
 
72
   final Widget body;
72
   final Widget body;
102
   const ZefyrToolbar({
102
   const ZefyrToolbar({
103
     Key key,
103
     Key key,
104
     @required this.editor,
104
     @required this.editor,
105
-    this.autoHide: true,
105
+    this.autoHide = true,
106
     this.delegate,
106
     this.delegate,
107
   }) : super(key: key);
107
   }) : super(key: key);
108
 
108
 

+ 8
- 8
packages/zefyr/lib/src/widgets/view.dart 查看文件

86
   Widget _defaultChildBuilder(BuildContext context, Node node) {
86
   Widget _defaultChildBuilder(BuildContext context, Node node) {
87
     if (node is LineNode) {
87
     if (node is LineNode) {
88
       if (node.hasEmbed) {
88
       if (node.hasEmbed) {
89
-        return new RawZefyrLine(node: node);
89
+        return RawZefyrLine(node: node);
90
       } else if (node.style.contains(NotusAttribute.heading)) {
90
       } else if (node.style.contains(NotusAttribute.heading)) {
91
-        return new ZefyrHeading(node: node);
91
+        return ZefyrHeading(node: node);
92
       }
92
       }
93
-      return new ZefyrParagraph(node: node);
93
+      return ZefyrParagraph(node: node);
94
     }
94
     }
95
 
95
 
96
     final BlockNode block = node;
96
     final BlockNode block = node;
97
     final blockStyle = block.style.get(NotusAttribute.block);
97
     final blockStyle = block.style.get(NotusAttribute.block);
98
     if (blockStyle == NotusAttribute.block.code) {
98
     if (blockStyle == NotusAttribute.block.code) {
99
-      return new ZefyrCode(node: block);
99
+      return ZefyrCode(node: block);
100
     } else if (blockStyle == NotusAttribute.block.bulletList) {
100
     } else if (blockStyle == NotusAttribute.block.bulletList) {
101
-      return new ZefyrList(node: block);
101
+      return ZefyrList(node: block);
102
     } else if (blockStyle == NotusAttribute.block.numberList) {
102
     } else if (blockStyle == NotusAttribute.block.numberList) {
103
-      return new ZefyrList(node: block);
103
+      return ZefyrList(node: block);
104
     } else if (blockStyle == NotusAttribute.block.quote) {
104
     } else if (blockStyle == NotusAttribute.block.quote) {
105
-      return new ZefyrQuote(node: block);
105
+      return ZefyrQuote(node: block);
106
     }
106
     }
107
 
107
 
108
-    throw new UnimplementedError('Block format $blockStyle.');
108
+    throw UnimplementedError('Block format $blockStyle.');
109
   }
109
   }
110
 }
110
 }

+ 1
- 0
packages/zefyr/pubspec.yaml 查看文件

20
 dev_dependencies:
20
 dev_dependencies:
21
   flutter_test:
21
   flutter_test:
22
     sdk: flutter
22
     sdk: flutter
23
+  pedantic: ^1.0.0

+ 3
- 3
packages/zefyr/test/painting/caret_painter_test.dart 查看文件

10
 void main() {
10
 void main() {
11
   group('$CursorPainter', () {
11
   group('$CursorPainter', () {
12
     test('prototype is null before layout', () {
12
     test('prototype is null before layout', () {
13
-      var painter = new CursorPainter(Colors.black);
13
+      var painter = CursorPainter(Colors.black);
14
       expect(painter.prototype, isNull);
14
       expect(painter.prototype, isNull);
15
     });
15
     });
16
 
16
 
17
     test('prototype is set after layout', () {
17
     test('prototype is set after layout', () {
18
-      var painter = new CursorPainter(Colors.black);
18
+      var painter = CursorPainter(Colors.black);
19
       painter.layout(16.0);
19
       painter.layout(16.0);
20
-      expect(painter.prototype, new Rect.fromLTWH(0.0, 0.0, 1.0, 14.0));
20
+      expect(painter.prototype, Rect.fromLTWH(0.0, 0.0, 1.0, 14.0));
21
     });
21
     });
22
   });
22
   });
23
 }
23
 }

+ 1
- 1
packages/zefyr/test/rendering/render_editable_proxy_box_test.dart 查看文件

41
     });
41
     });
42
 
42
 
43
     test('it registers with render context', () {
43
     test('it registers with render context', () {
44
-      var owner = new PipelineOwner();
44
+      var owner = PipelineOwner();
45
       expect(renderContext.active, isNot(contains(p)));
45
       expect(renderContext.active, isNot(contains(p)));
46
       p.attach(owner);
46
       p.attach(owner);
47
       expect(renderContext.dirty, contains(p));
47
       expect(renderContext.dirty, contains(p));

+ 6
- 6
packages/zefyr/test/rendering/render_zefyr_paragraph_test.dart 查看文件

12
 
12
 
13
 void main() {
13
 void main() {
14
   group('$RenderZefyrParagraph', () {
14
   group('$RenderZefyrParagraph', () {
15
-    final doc = new NotusDocument();
15
+    final doc = NotusDocument();
16
     doc.insert(0, 'This House Is A Circus');
16
     doc.insert(0, 'This House Is A Circus');
17
-    final text = new TextSpan(text: 'This House Is A Circus');
17
+    final text = TextSpan(text: 'This House Is A Circus');
18
 
18
 
19
     ZefyrRenderContext renderContext;
19
     ZefyrRenderContext renderContext;
20
     RenderZefyrParagraph p;
20
     RenderZefyrParagraph p;
21
 
21
 
22
     setUp(() {
22
     setUp(() {
23
       WidgetsFlutterBinding.ensureInitialized();
23
       WidgetsFlutterBinding.ensureInitialized();
24
-      renderContext = new ZefyrRenderContext();
25
-      p = new RenderZefyrParagraph(
24
+      renderContext = ZefyrRenderContext();
25
+      p = RenderZefyrParagraph(
26
         text,
26
         text,
27
         node: doc.root.children.first as LineNode,
27
         node: doc.root.children.first as LineNode,
28
         textDirection: TextDirection.ltr,
28
         textDirection: TextDirection.ltr,
30
     });
30
     });
31
 
31
 
32
     test('it registers with viewport', () {
32
     test('it registers with viewport', () {
33
-      var owner = new PipelineOwner();
33
+      var owner = PipelineOwner();
34
       expect(renderContext.active, isNot(contains(p)));
34
       expect(renderContext.active, isNot(contains(p)));
35
       p.attach(owner);
35
       p.attach(owner);
36
       expect(renderContext.dirty, contains(p));
36
       expect(renderContext.dirty, contains(p));
37
-      p.layout(new BoxConstraints());
37
+      p.layout(BoxConstraints());
38
       expect(renderContext.active, contains(p));
38
       expect(renderContext.active, contains(p));
39
     }, skip: 'TODO: move to RenderEditableProxyBox');
39
     }, skip: 'TODO: move to RenderEditableProxyBox');
40
   });
40
   });

+ 4
- 4
packages/zefyr/test/testing.dart 查看文件

7
 import 'package:zefyr/src/widgets/selection.dart';
7
 import 'package:zefyr/src/widgets/selection.dart';
8
 import 'package:zefyr/zefyr.dart';
8
 import 'package:zefyr/zefyr.dart';
9
 
9
 
10
-var delta = new Delta()..insert('This House Is A Circus\n');
10
+var delta = Delta()..insert('This House Is A Circus\n');
11
 
11
 
12
 class EditorSandBox {
12
 class EditorSandBox {
13
   final WidgetTester tester;
13
   final WidgetTester tester;
21
     FocusNode focusNode,
21
     FocusNode focusNode,
22
     NotusDocument document,
22
     NotusDocument document,
23
     ZefyrThemeData theme,
23
     ZefyrThemeData theme,
24
-    bool autofocus: false,
24
+    bool autofocus = false,
25
     ZefyrImageDelegate imageDelegate,
25
     ZefyrImageDelegate imageDelegate,
26
   }) {
26
   }) {
27
     focusNode ??= FocusNode();
27
     focusNode ??= FocusNode();
57
 
57
 
58
   Future<void> updateSelection({int base, int extent}) {
58
   Future<void> updateSelection({int base, int extent}) {
59
     controller.updateSelection(
59
     controller.updateSelection(
60
-      new TextSelection(baseOffset: base, extentOffset: extent),
60
+      TextSelection(baseOffset: base, extentOffset: extent),
61
     );
61
     );
62
     return tester.pumpAndSettle();
62
     return tester.pumpAndSettle();
63
   }
63
   }
138
 
138
 
139
   @override
139
   @override
140
   Widget build(BuildContext context) {
140
   Widget build(BuildContext context) {
141
-    return new ZefyrEditor(
141
+    return ZefyrEditor(
142
       controller: widget.controller,
142
       controller: widget.controller,
143
       focusNode: widget.focusNode,
143
       focusNode: widget.focusNode,
144
       mode: _enabled ? ZefyrMode.edit : ZefyrMode.view,
144
       mode: _enabled ? ZefyrMode.edit : ZefyrMode.view,

+ 6
- 6
packages/zefyr/test/util_test.dart 查看文件

8
 void main() {
8
 void main() {
9
   group('getPositionDelta', () {
9
   group('getPositionDelta', () {
10
     test('actual has more characters inserted than user', () {
10
     test('actual has more characters inserted than user', () {
11
-      final user = new Delta()
11
+      final user = Delta()
12
         ..retain(7)
12
         ..retain(7)
13
         ..insert('a');
13
         ..insert('a');
14
-      final actual = new Delta()
14
+      final actual = Delta()
15
         ..retain(7)
15
         ..retain(7)
16
         ..insert('\na');
16
         ..insert('\na');
17
       final result = getPositionDelta(user, actual);
17
       final result = getPositionDelta(user, actual);
19
     });
19
     });
20
 
20
 
21
     test('actual has less characters inserted than user', () {
21
     test('actual has less characters inserted than user', () {
22
-      final user = new Delta()
22
+      final user = Delta()
23
         ..retain(7)
23
         ..retain(7)
24
         ..insert('abc');
24
         ..insert('abc');
25
-      final actual = new Delta()
25
+      final actual = Delta()
26
         ..retain(7)
26
         ..retain(7)
27
         ..insert('ab');
27
         ..insert('ab');
28
       final result = getPositionDelta(user, actual);
28
       final result = getPositionDelta(user, actual);
30
     });
30
     });
31
 
31
 
32
     test('actual has less characters deleted than user', () {
32
     test('actual has less characters deleted than user', () {
33
-      final user = new Delta()
33
+      final user = Delta()
34
         ..retain(7)
34
         ..retain(7)
35
         ..delete(3);
35
         ..delete(3);
36
-      final actual = new Delta()
36
+      final actual = Delta()
37
         ..retain(7)
37
         ..retain(7)
38
         ..delete(2);
38
         ..delete(2);
39
       final result = getPositionDelta(user, actual);
39
       final result = getPositionDelta(user, actual);

+ 12
- 12
packages/zefyr/test/widgets/buttons_test.dart 查看文件

13
 void main() {
13
 void main() {
14
   group('$ZefyrButton', () {
14
   group('$ZefyrButton', () {
15
     testWidgets('toggle style', (tester) async {
15
     testWidgets('toggle style', (tester) async {
16
-      final editor = new EditorSandBox(tester: tester);
16
+      final editor = EditorSandBox(tester: tester);
17
       await editor.pumpAndTap();
17
       await editor.pumpAndTap();
18
       await editor.updateSelection(base: 5, extent: 10);
18
       await editor.updateSelection(base: 5, extent: 10);
19
       await editor.tapButtonWithIcon(Icons.format_bold);
19
       await editor.tapButtonWithIcon(Icons.format_bold);
31
 
31
 
32
     testWidgets('toggle state for different styles of the same attribute',
32
     testWidgets('toggle state for different styles of the same attribute',
33
         (tester) async {
33
         (tester) async {
34
-      final editor = new EditorSandBox(tester: tester);
34
+      final editor = EditorSandBox(tester: tester);
35
       await editor.pumpAndTap();
35
       await editor.pumpAndTap();
36
 
36
 
37
       await editor.tapButtonWithIcon(Icons.format_list_bulleted);
37
       await editor.tapButtonWithIcon(Icons.format_list_bulleted);
46
 
46
 
47
   group('$HeadingButton', () {
47
   group('$HeadingButton', () {
48
     testWidgets('toggle menu', (tester) async {
48
     testWidgets('toggle menu', (tester) async {
49
-      final editor = new EditorSandBox(tester: tester);
49
+      final editor = EditorSandBox(tester: tester);
50
       await editor.pumpAndTap();
50
       await editor.pumpAndTap();
51
       await editor.tapButtonWithIcon(Icons.format_size);
51
       await editor.tapButtonWithIcon(Icons.format_size);
52
 
52
 
60
     });
60
     });
61
 
61
 
62
     testWidgets('toggle styles', (tester) async {
62
     testWidgets('toggle styles', (tester) async {
63
-      final editor = new EditorSandBox(tester: tester);
63
+      final editor = EditorSandBox(tester: tester);
64
       await editor.pumpAndTap();
64
       await editor.pumpAndTap();
65
       await editor.tapButtonWithIcon(Icons.format_size);
65
       await editor.tapButtonWithIcon(Icons.format_size);
66
       await editor.tapButtonWithText('H3');
66
       await editor.tapButtonWithText('H3');
71
     });
71
     });
72
 
72
 
73
     testWidgets('close overlay', (tester) async {
73
     testWidgets('close overlay', (tester) async {
74
-      final editor = new EditorSandBox(tester: tester);
74
+      final editor = EditorSandBox(tester: tester);
75
       await editor.pumpAndTap();
75
       await editor.pumpAndTap();
76
       await editor.tapButtonWithIcon(Icons.format_size);
76
       await editor.tapButtonWithIcon(Icons.format_size);
77
       expect(find.text('H1'), findsOneWidget);
77
       expect(find.text('H1'), findsOneWidget);
82
 
82
 
83
   group('$LinkButton', () {
83
   group('$LinkButton', () {
84
     testWidgets('disabled when selection is collapsed', (tester) async {
84
     testWidgets('disabled when selection is collapsed', (tester) async {
85
-      final editor = new EditorSandBox(tester: tester);
85
+      final editor = EditorSandBox(tester: tester);
86
       await editor.pumpAndTap();
86
       await editor.pumpAndTap();
87
       await editor.tapButtonWithIcon(Icons.link);
87
       await editor.tapButtonWithIcon(Icons.link);
88
       expect(find.byIcon(Icons.link_off), findsNothing);
88
       expect(find.byIcon(Icons.link_off), findsNothing);
90
 
90
 
91
     testWidgets('enabled and toggles menu with non-empty selection',
91
     testWidgets('enabled and toggles menu with non-empty selection',
92
         (tester) async {
92
         (tester) async {
93
-      final editor = new EditorSandBox(tester: tester);
93
+      final editor = EditorSandBox(tester: tester);
94
       await editor.pumpAndTap();
94
       await editor.pumpAndTap();
95
       await editor.updateSelection(base: 5, extent: 10);
95
       await editor.updateSelection(base: 5, extent: 10);
96
       await editor.tapButtonWithIcon(Icons.link);
96
       await editor.tapButtonWithIcon(Icons.link);
98
     });
98
     });
99
 
99
 
100
     testWidgets('auto cancels edit on selection update', (tester) async {
100
     testWidgets('auto cancels edit on selection update', (tester) async {
101
-      final editor = new EditorSandBox(tester: tester);
101
+      final editor = EditorSandBox(tester: tester);
102
       await editor.pumpAndTap();
102
       await editor.pumpAndTap();
103
       await editor.updateSelection(base: 5, extent: 10);
103
       await editor.updateSelection(base: 5, extent: 10);
104
       await editor.tapButtonWithIcon(Icons.link);
104
       await editor.tapButtonWithIcon(Icons.link);
111
     });
111
     });
112
 
112
 
113
     testWidgets('editing link', (tester) async {
113
     testWidgets('editing link', (tester) async {
114
-      final editor = new EditorSandBox(tester: tester);
114
+      final editor = EditorSandBox(tester: tester);
115
       await editor.pumpAndTap();
115
       await editor.pumpAndTap();
116
       await editor.updateSelection(base: 5, extent: 10);
116
       await editor.updateSelection(base: 5, extent: 10);
117
 
117
 
147
 
147
 
148
   group('$ImageButton', () {
148
   group('$ImageButton', () {
149
     testWidgets('toggle overlay', (tester) async {
149
     testWidgets('toggle overlay', (tester) async {
150
-      final editor = new EditorSandBox(
150
+      final editor = EditorSandBox(
151
         tester: tester,
151
         tester: tester,
152
         imageDelegate: _TestImageDelegate(),
152
         imageDelegate: _TestImageDelegate(),
153
       );
153
       );
160
     });
160
     });
161
 
161
 
162
     testWidgets('pick from camera', (tester) async {
162
     testWidgets('pick from camera', (tester) async {
163
-      final editor = new EditorSandBox(
163
+      final editor = EditorSandBox(
164
         tester: tester,
164
         tester: tester,
165
         imageDelegate: _TestImageDelegate(),
165
         imageDelegate: _TestImageDelegate(),
166
       );
166
       );
171
     });
171
     });
172
 
172
 
173
     testWidgets('pick from gallery', (tester) async {
173
     testWidgets('pick from gallery', (tester) async {
174
-      final editor = new EditorSandBox(
174
+      final editor = EditorSandBox(
175
         tester: tester,
175
         tester: tester,
176
         imageDelegate: _TestImageDelegate(),
176
         imageDelegate: _TestImageDelegate(),
177
       );
177
       );

+ 1
- 1
packages/zefyr/test/widgets/code_test.dart 查看文件

10
 void main() {
10
 void main() {
11
   group('$ZefyrCode', () {
11
   group('$ZefyrCode', () {
12
     testWidgets('format as code', (tester) async {
12
     testWidgets('format as code', (tester) async {
13
-      final editor = new EditorSandBox(tester: tester);
13
+      final editor = EditorSandBox(tester: tester);
14
       await editor.pumpAndTap();
14
       await editor.pumpAndTap();
15
       await editor.tapButtonWithIcon(Icons.code);
15
       await editor.tapButtonWithIcon(Icons.code);
16
 
16
 

+ 18
- 18
packages/zefyr/test/widgets/controller_test.dart 查看文件

11
     ZefyrController controller;
11
     ZefyrController controller;
12
 
12
 
13
     setUp(() {
13
     setUp(() {
14
-      var doc = new NotusDocument();
15
-      controller = new ZefyrController(doc);
14
+      var doc = NotusDocument();
15
+      controller = ZefyrController(doc);
16
     });
16
     });
17
 
17
 
18
     test('dispose', () {
18
     test('dispose', () {
25
       controller.addListener(() {
25
       controller.addListener(() {
26
         notified = true;
26
         notified = true;
27
       });
27
       });
28
-      controller.updateSelection(new TextSelection.collapsed(offset: 0));
28
+      controller.updateSelection(TextSelection.collapsed(offset: 0));
29
       expect(notified, isTrue);
29
       expect(notified, isTrue);
30
-      expect(controller.selection, new TextSelection.collapsed(offset: 0));
30
+      expect(controller.selection, TextSelection.collapsed(offset: 0));
31
       expect(controller.lastChangeSource, ChangeSource.remote);
31
       expect(controller.lastChangeSource, ChangeSource.remote);
32
     });
32
     });
33
 
33
 
36
       controller.addListener(() {
36
       controller.addListener(() {
37
         notified = true;
37
         notified = true;
38
       });
38
       });
39
-      var selection = new TextSelection.collapsed(offset: 5);
40
-      var change = new Delta()..insert('Words');
39
+      var selection = TextSelection.collapsed(offset: 5);
40
+      var change = Delta()..insert('Words');
41
       controller.compose(change, selection: selection);
41
       controller.compose(change, selection: selection);
42
       expect(notified, isTrue);
42
       expect(notified, isTrue);
43
       expect(controller.selection, selection);
43
       expect(controller.selection, selection);
44
-      expect(controller.document.toDelta(), new Delta()..insert('Words\n'));
44
+      expect(controller.document.toDelta(), Delta()..insert('Words\n'));
45
       expect(controller.lastChangeSource, ChangeSource.remote);
45
       expect(controller.lastChangeSource, ChangeSource.remote);
46
     });
46
     });
47
 
47
 
50
       controller.addListener(() {
50
       controller.addListener(() {
51
         notified = true;
51
         notified = true;
52
       });
52
       });
53
-      var selection = new TextSelection.collapsed(offset: 5);
54
-      var change = new Delta()..insert('Words');
53
+      var selection = TextSelection.collapsed(offset: 5);
54
+      var change = Delta()..insert('Words');
55
       controller.compose(change, selection: selection);
55
       controller.compose(change, selection: selection);
56
-      var change2 = new Delta()..insert('More ');
56
+      var change2 = Delta()..insert('More ');
57
       controller.compose(change2);
57
       controller.compose(change2);
58
       expect(notified, isTrue);
58
       expect(notified, isTrue);
59
-      var expectedSelection = new TextSelection.collapsed(offset: 10);
59
+      var expectedSelection = TextSelection.collapsed(offset: 10);
60
       expect(controller.selection, expectedSelection);
60
       expect(controller.selection, expectedSelection);
61
       expect(
61
       expect(
62
-          controller.document.toDelta(), new Delta()..insert('More Words\n'));
62
+          controller.document.toDelta(), Delta()..insert('More Words\n'));
63
       expect(controller.lastChangeSource, ChangeSource.remote);
63
       expect(controller.lastChangeSource, ChangeSource.remote);
64
     });
64
     });
65
 
65
 
68
       controller.addListener(() {
68
       controller.addListener(() {
69
         notified = true;
69
         notified = true;
70
       });
70
       });
71
-      var selection = new TextSelection.collapsed(offset: 5);
71
+      var selection = TextSelection.collapsed(offset: 5);
72
       controller.replaceText(0, 0, 'Words', selection: selection);
72
       controller.replaceText(0, 0, 'Words', selection: selection);
73
       expect(notified, isTrue);
73
       expect(notified, isTrue);
74
       expect(controller.selection, selection);
74
       expect(controller.selection, selection);
75
-      expect(controller.document.toDelta(), new Delta()..insert('Words\n'));
75
+      expect(controller.document.toDelta(), Delta()..insert('Words\n'));
76
       expect(controller.lastChangeSource, ChangeSource.local);
76
       expect(controller.lastChangeSource, ChangeSource.local);
77
     });
77
     });
78
 
78
 
86
       expect(notified, isTrue);
86
       expect(notified, isTrue);
87
       expect(
87
       expect(
88
         controller.document.toDelta(),
88
         controller.document.toDelta(),
89
-        new Delta()
89
+        Delta()
90
           ..insert('Words', NotusAttribute.bold.toJson())
90
           ..insert('Words', NotusAttribute.bold.toJson())
91
           ..insert('\n'),
91
           ..insert('\n'),
92
       );
92
       );
98
       controller.addListener(() {
98
       controller.addListener(() {
99
         notified = true;
99
         notified = true;
100
       });
100
       });
101
-      var selection = new TextSelection(baseOffset: 0, extentOffset: 5);
101
+      var selection = TextSelection(baseOffset: 0, extentOffset: 5);
102
       controller.replaceText(0, 0, 'Words', selection: selection);
102
       controller.replaceText(0, 0, 'Words', selection: selection);
103
       controller.formatSelection(NotusAttribute.bold);
103
       controller.formatSelection(NotusAttribute.bold);
104
       expect(notified, isTrue);
104
       expect(notified, isTrue);
105
       expect(
105
       expect(
106
         controller.document.toDelta(),
106
         controller.document.toDelta(),
107
-        new Delta()
107
+        Delta()
108
           ..insert('Words', NotusAttribute.bold.toJson())
108
           ..insert('Words', NotusAttribute.bold.toJson())
109
           ..insert('\n'),
109
           ..insert('\n'),
110
       );
110
       );
112
     });
112
     });
113
 
113
 
114
     test('getSelectionStyle', () {
114
     test('getSelectionStyle', () {
115
-      var selection = new TextSelection.collapsed(offset: 3);
115
+      var selection = TextSelection.collapsed(offset: 3);
116
       controller.replaceText(0, 0, 'Words', selection: selection);
116
       controller.replaceText(0, 0, 'Words', selection: selection);
117
       controller.formatText(0, 5, NotusAttribute.bold);
117
       controller.formatText(0, 5, NotusAttribute.bold);
118
       var result = controller.getSelectionStyle();
118
       var result = controller.getSelectionStyle();

+ 5
- 5
packages/zefyr/test/widgets/editable_text_test.dart 查看文件

10
 void main() {
10
 void main() {
11
   group('$ZefyrEditableText', () {
11
   group('$ZefyrEditableText', () {
12
     testWidgets('user input', (tester) async {
12
     testWidgets('user input', (tester) async {
13
-      final editor = new EditorSandBox(tester: tester);
13
+      final editor = EditorSandBox(tester: tester);
14
       await editor.pumpAndTap();
14
       await editor.pumpAndTap();
15
       final currentValue = editor.document.toPlainText();
15
       final currentValue = editor.document.toPlainText();
16
       await enterText(tester, 'Added $currentValue');
16
       await enterText(tester, 'Added $currentValue');
18
     });
18
     });
19
 
19
 
20
     testWidgets('autofocus', (tester) async {
20
     testWidgets('autofocus', (tester) async {
21
-      final editor = new EditorSandBox(tester: tester, autofocus: true);
21
+      final editor = EditorSandBox(tester: tester, autofocus: true);
22
       await editor.pump();
22
       await editor.pump();
23
       expect(editor.focusNode.hasFocus, isTrue);
23
       expect(editor.focusNode.hasFocus, isTrue);
24
     });
24
     });
25
 
25
 
26
     testWidgets('no autofocus', (tester) async {
26
     testWidgets('no autofocus', (tester) async {
27
-      final editor = new EditorSandBox(tester: tester);
27
+      final editor = EditorSandBox(tester: tester);
28
       await editor.pump();
28
       await editor.pump();
29
       expect(editor.focusNode.hasFocus, isFalse);
29
       expect(editor.focusNode.hasFocus, isFalse);
30
     });
30
     });
34
 Future<Null> enterText(WidgetTester tester, String text) async {
34
 Future<Null> enterText(WidgetTester tester, String text) async {
35
   return TestAsyncUtils.guard(() async {
35
   return TestAsyncUtils.guard(() async {
36
     tester.testTextInput.updateEditingValue(
36
     tester.testTextInput.updateEditingValue(
37
-      new TextEditingValue(
37
+      TextEditingValue(
38
         text: text,
38
         text: text,
39
-        selection: new TextSelection.collapsed(offset: 6),
39
+        selection: TextSelection.collapsed(offset: 6),
40
       ),
40
       ),
41
     );
41
     );
42
     await tester.idle();
42
     await tester.idle();

+ 5
- 5
packages/zefyr/test/widgets/editor_test.dart 查看文件

12
 void main() {
12
 void main() {
13
   group('$ZefyrEditor', () {
13
   group('$ZefyrEditor', () {
14
     testWidgets('allows merging theme data', (tester) async {
14
     testWidgets('allows merging theme data', (tester) async {
15
-      var delta = new Delta()
15
+      var delta = Delta()
16
         ..insert(
16
         ..insert(
17
           'Website',
17
           'Website',
18
           NotusAttribute.link.fromString('https://github.com').toJson(),
18
           NotusAttribute.link.fromString('https://github.com').toJson(),
19
         )
19
         )
20
         ..insert('\n');
20
         ..insert('\n');
21
-      var doc = new NotusDocument.fromDelta(delta);
21
+      var doc = NotusDocument.fromDelta(delta);
22
       var theme = ZefyrThemeData(linkStyle: TextStyle(color: Colors.red));
22
       var theme = ZefyrThemeData(linkStyle: TextStyle(color: Colors.red));
23
       var editor =
23
       var editor =
24
-          new EditorSandBox(tester: tester, document: doc, theme: theme);
24
+          EditorSandBox(tester: tester, document: doc, theme: theme);
25
       await editor.pumpAndTap();
25
       await editor.pumpAndTap();
26
       // TODO: figure out why this extra pump is needed here
26
       // TODO: figure out why this extra pump is needed here
27
       await tester.pumpAndSettle();
27
       await tester.pumpAndSettle();
30
     });
30
     });
31
 
31
 
32
     testWidgets('collapses selection when unfocused', (tester) async {
32
     testWidgets('collapses selection when unfocused', (tester) async {
33
-      final editor = new EditorSandBox(tester: tester);
33
+      final editor = EditorSandBox(tester: tester);
34
       await editor.pumpAndTap();
34
       await editor.pumpAndTap();
35
       await editor.updateSelection(base: 0, extent: 3);
35
       await editor.updateSelection(base: 0, extent: 3);
36
       expect(editor.findSelectionHandle(), findsNWidgets(2));
36
       expect(editor.findSelectionHandle(), findsNWidgets(2));
40
     });
40
     });
41
 
41
 
42
     testWidgets('toggle enabled state', (tester) async {
42
     testWidgets('toggle enabled state', (tester) async {
43
-      final editor = new EditorSandBox(tester: tester);
43
+      final editor = EditorSandBox(tester: tester);
44
       await editor.pumpAndTap();
44
       await editor.pumpAndTap();
45
       await editor.updateSelection(base: 0, extent: 3);
45
       await editor.updateSelection(base: 0, extent: 3);
46
       await editor.disable();
46
       await editor.disable();

+ 5
- 5
packages/zefyr/test/widgets/horizontal_rule_test.dart 查看文件

10
 void main() {
10
 void main() {
11
   group('$ZefyrHorizontalRule', () {
11
   group('$ZefyrHorizontalRule', () {
12
     testWidgets('format as horizontal rule', (tester) async {
12
     testWidgets('format as horizontal rule', (tester) async {
13
-      final editor = new EditorSandBox(tester: tester);
13
+      final editor = EditorSandBox(tester: tester);
14
       await editor.pumpAndTap();
14
       await editor.pumpAndTap();
15
       await editor.tapButtonWithIcon(Icons.remove);
15
       await editor.tapButtonWithIcon(Icons.remove);
16
 
16
 
20
 
20
 
21
     testWidgets('tap left side of horizontal rule puts caret before it',
21
     testWidgets('tap left side of horizontal rule puts caret before it',
22
         (tester) async {
22
         (tester) async {
23
-      final editor = new EditorSandBox(tester: tester);
23
+      final editor = EditorSandBox(tester: tester);
24
       await editor.pumpAndTap();
24
       await editor.pumpAndTap();
25
       await editor.tapButtonWithIcon(Icons.remove);
25
       await editor.tapButtonWithIcon(Icons.remove);
26
       await editor.updateSelection(base: 0, extent: 0);
26
       await editor.updateSelection(base: 0, extent: 0);
34
 
34
 
35
     testWidgets('tap right side of horizontal rule puts caret after it',
35
     testWidgets('tap right side of horizontal rule puts caret after it',
36
         (tester) async {
36
         (tester) async {
37
-      final editor = new EditorSandBox(tester: tester);
37
+      final editor = EditorSandBox(tester: tester);
38
       await editor.pumpAndTap();
38
       await editor.pumpAndTap();
39
       await editor.tapButtonWithIcon(Icons.remove);
39
       await editor.tapButtonWithIcon(Icons.remove);
40
       await editor.updateSelection(base: 0, extent: 0);
40
       await editor.updateSelection(base: 0, extent: 0);
41
 
41
 
42
       final hr = find.byType(ZefyrHorizontalRule);
42
       final hr = find.byType(ZefyrHorizontalRule);
43
-      final offset = tester.getBottomRight(hr) - new Offset(1.0, 1.0);
43
+      final offset = tester.getBottomRight(hr) - Offset(1.0, 1.0);
44
       await tester.tapAt(offset);
44
       await tester.tapAt(offset);
45
       LineNode line = editor.document.root.children.last;
45
       LineNode line = editor.document.root.children.last;
46
       EmbedNode embed = line.children.single;
46
       EmbedNode embed = line.children.single;
50
 
50
 
51
     testWidgets('selects on long press',
51
     testWidgets('selects on long press',
52
         (tester) async {
52
         (tester) async {
53
-      final editor = new EditorSandBox(tester: tester);
53
+      final editor = EditorSandBox(tester: tester);
54
       await editor.pumpAndTap();
54
       await editor.pumpAndTap();
55
       await editor.tapButtonWithIcon(Icons.remove);
55
       await editor.tapButtonWithIcon(Icons.remove);
56
       await editor.updateSelection(base: 0, extent: 0);
56
       await editor.updateSelection(base: 0, extent: 0);

+ 5
- 5
packages/zefyr/test/widgets/image_test.dart 查看文件

12
 void main() {
12
 void main() {
13
   group('$ZefyrImage', () {
13
   group('$ZefyrImage', () {
14
     testWidgets('embed image', (tester) async {
14
     testWidgets('embed image', (tester) async {
15
-      final editor = new EditorSandBox(
15
+      final editor = EditorSandBox(
16
         tester: tester,
16
         tester: tester,
17
         imageDelegate: _TestImageDelegate(),
17
         imageDelegate: _TestImageDelegate(),
18
       );
18
       );
31
 
31
 
32
     testWidgets('tap on left side of image puts caret before it',
32
     testWidgets('tap on left side of image puts caret before it',
33
         (tester) async {
33
         (tester) async {
34
-      final editor = new EditorSandBox(
34
+      final editor = EditorSandBox(
35
         tester: tester,
35
         tester: tester,
36
         imageDelegate: _TestImageDelegate(),
36
         imageDelegate: _TestImageDelegate(),
37
       );
37
       );
48
     });
48
     });
49
 
49
 
50
     testWidgets('tap right side of image puts caret after it', (tester) async {
50
     testWidgets('tap right side of image puts caret after it', (tester) async {
51
-      final editor = new EditorSandBox(
51
+      final editor = EditorSandBox(
52
         tester: tester,
52
         tester: tester,
53
         imageDelegate: _TestImageDelegate(),
53
         imageDelegate: _TestImageDelegate(),
54
       );
54
       );
58
       await editor.updateSelection(base: 0, extent: 0);
58
       await editor.updateSelection(base: 0, extent: 0);
59
 
59
 
60
       final img = find.byType(ZefyrImage);
60
       final img = find.byType(ZefyrImage);
61
-      final offset = tester.getBottomRight(img) - new Offset(1.0, 1.0);
61
+      final offset = tester.getBottomRight(img) - Offset(1.0, 1.0);
62
       await tester.tapAt(offset);
62
       await tester.tapAt(offset);
63
       LineNode line = editor.document.root.children.last;
63
       LineNode line = editor.document.root.children.last;
64
       EmbedNode embed = line.children.single;
64
       EmbedNode embed = line.children.single;
67
     });
67
     });
68
 
68
 
69
     testWidgets('selects on long press', (tester) async {
69
     testWidgets('selects on long press', (tester) async {
70
-      final editor = new EditorSandBox(
70
+      final editor = EditorSandBox(
71
         tester: tester,
71
         tester: tester,
72
         imageDelegate: _TestImageDelegate(),
72
         imageDelegate: _TestImageDelegate(),
73
       );
73
       );

+ 1
- 1
packages/zefyr/test/widgets/list_test.dart 查看文件

10
 void main() {
10
 void main() {
11
   group('$ZefyrList', () {
11
   group('$ZefyrList', () {
12
     testWidgets('format as list', (tester) async {
12
     testWidgets('format as list', (tester) async {
13
-      final editor = new EditorSandBox(tester: tester);
13
+      final editor = EditorSandBox(tester: tester);
14
       await editor.pumpAndTap();
14
       await editor.pumpAndTap();
15
       await editor.tapButtonWithIcon(Icons.format_list_bulleted);
15
       await editor.tapButtonWithIcon(Icons.format_list_bulleted);
16
       BlockNode block = editor.document.root.children.first;
16
       BlockNode block = editor.document.root.children.first;

+ 1
- 1
packages/zefyr/test/widgets/quote_test.dart 查看文件

10
 void main() {
10
 void main() {
11
   group('$ZefyrQuote', () {
11
   group('$ZefyrQuote', () {
12
     testWidgets('format as quote', (tester) async {
12
     testWidgets('format as quote', (tester) async {
13
-      final editor = new EditorSandBox(tester: tester);
13
+      final editor = EditorSandBox(tester: tester);
14
       await editor.pumpAndTap();
14
       await editor.pumpAndTap();
15
       await editor.tapButtonWithIcon(Icons.format_quote);
15
       await editor.tapButtonWithIcon(Icons.format_quote);
16
 
16
 

+ 7
- 7
packages/zefyr/test/widgets/render_context_test.dart 查看文件

13
 
13
 
14
     setUp(() {
14
     setUp(() {
15
       WidgetsFlutterBinding.ensureInitialized();
15
       WidgetsFlutterBinding.ensureInitialized();
16
-      context = new ZefyrRenderContext();
16
+      context = ZefyrRenderContext();
17
     });
17
     });
18
 
18
 
19
     test('adds to dirty list first', () {
19
     test('adds to dirty list first', () {
53
 
53
 
54
     testWidgets('notifyListeners is delayed to next frame', (tester) async {
54
     testWidgets('notifyListeners is delayed to next frame', (tester) async {
55
       var focusNode = FocusNode();
55
       var focusNode = FocusNode();
56
-      var controller = ZefyrController(new NotusDocument());
56
+      var controller = ZefyrController(NotusDocument());
57
       var widget = MaterialApp(
57
       var widget = MaterialApp(
58
         home: ZefyrScaffold(
58
         home: ZefyrScaffold(
59
           child: ZefyrEditor(
59
           child: ZefyrEditor(
71
 }
71
 }
72
 
72
 
73
 RenderEditableProxyBox createParagraph(ZefyrRenderContext viewport) {
73
 RenderEditableProxyBox createParagraph(ZefyrRenderContext viewport) {
74
-  final doc = new NotusDocument();
74
+  final doc = NotusDocument();
75
   doc.insert(0, 'This House Is A Circus');
75
   doc.insert(0, 'This House Is A Circus');
76
   final LineNode node = doc.root.children.first;
76
   final LineNode node = doc.root.children.first;
77
-  final link = new LayerLink();
78
-  final showCursor = new ValueNotifier<bool>(true);
79
-  final selection = new TextSelection.collapsed(offset: 0);
77
+  final link = LayerLink();
78
+  final showCursor = ValueNotifier<bool>(true);
79
+  final selection = TextSelection.collapsed(offset: 0);
80
   final selectionColor = Colors.blue;
80
   final selectionColor = Colors.blue;
81
-  return new RenderEditableProxyBox(
81
+  return RenderEditableProxyBox(
82
     node: node,
82
     node: node,
83
     layerLink: link,
83
     layerLink: link,
84
     renderContext: viewport,
84
     renderContext: viewport,

+ 4
- 4
packages/zefyr/test/widgets/rich_text_test.dart 查看文件

10
 
10
 
11
 void main() {
11
 void main() {
12
   group('$ZefyrRichText', () {
12
   group('$ZefyrRichText', () {
13
-    final doc = new NotusDocument();
13
+    final doc = NotusDocument();
14
     doc.insert(0, 'This House Is A Circus');
14
     doc.insert(0, 'This House Is A Circus');
15
-    final text = new TextSpan(text: 'This House Is A Circus');
15
+    final text = TextSpan(text: 'This House Is A Circus');
16
 
16
 
17
     Widget widget;
17
     Widget widget;
18
     setUp(() {
18
     setUp(() {
19
-      widget = new Directionality(
19
+      widget = Directionality(
20
         textDirection: TextDirection.ltr,
20
         textDirection: TextDirection.ltr,
21
-        child: new ZefyrRichText(
21
+        child: ZefyrRichText(
22
           node: doc.root.children.first as LineNode,
22
           node: doc.root.children.first as LineNode,
23
           text: text,
23
           text: text,
24
         ),
24
         ),

+ 6
- 6
packages/zefyr/test/widgets/selection_test.dart 查看文件

11
 void main() {
11
 void main() {
12
   group('$ZefyrSelectionOverlay', () {
12
   group('$ZefyrSelectionOverlay', () {
13
     testWidgets('double tap caret shows toolbar', (tester) async {
13
     testWidgets('double tap caret shows toolbar', (tester) async {
14
-      final editor = new EditorSandBox(tester: tester);
14
+      final editor = EditorSandBox(tester: tester);
15
       await editor.pumpAndTap();
15
       await editor.pumpAndTap();
16
 
16
 
17
       RenderZefyrParagraph renderObject =
17
       RenderZefyrParagraph renderObject =
26
     });
26
     });
27
 
27
 
28
     testWidgets('hides when editor lost focus', (tester) async {
28
     testWidgets('hides when editor lost focus', (tester) async {
29
-      final editor = new EditorSandBox(tester: tester);
29
+      final editor = EditorSandBox(tester: tester);
30
       await editor.pumpAndTap();
30
       await editor.pumpAndTap();
31
       await editor.updateSelection(base: 0, extent: 5);
31
       await editor.updateSelection(base: 0, extent: 5);
32
       expect(editor.findSelectionHandle(), findsNWidgets(2));
32
       expect(editor.findSelectionHandle(), findsNWidgets(2));
35
     });
35
     });
36
 
36
 
37
     testWidgets('tap on padding area finds closest paragraph', (tester) async {
37
     testWidgets('tap on padding area finds closest paragraph', (tester) async {
38
-      final editor = new EditorSandBox(tester: tester);
38
+      final editor = EditorSandBox(tester: tester);
39
       await editor.pumpAndTap();
39
       await editor.pumpAndTap();
40
       editor.controller
40
       editor.controller
41
-          .updateSelection(new TextSelection.collapsed(offset: 10));
41
+          .updateSelection(TextSelection.collapsed(offset: 10));
42
       await tester.pumpAndSettle();
42
       await tester.pumpAndSettle();
43
       expect(editor.controller.selection.extentOffset, 10);
43
       expect(editor.controller.selection.extentOffset, 10);
44
 
44
 
53
     });
53
     });
54
 
54
 
55
     testWidgets('tap on empty space finds closest paragraph', (tester) async {
55
     testWidgets('tap on empty space finds closest paragraph', (tester) async {
56
-      final editor = new EditorSandBox(tester: tester);
56
+      final editor = EditorSandBox(tester: tester);
57
       await editor.pumpAndTap();
57
       await editor.pumpAndTap();
58
       editor.controller.replaceText(10, 1, '\n',
58
       editor.controller.replaceText(10, 1, '\n',
59
-          selection: new TextSelection.collapsed(offset: 0));
59
+          selection: TextSelection.collapsed(offset: 0));
60
       await tester.pumpAndSettle();
60
       await tester.pumpAndSettle();
61
       expect(editor.controller.document.toPlainText(),
61
       expect(editor.controller.document.toPlainText(),
62
           'This House\nIs A Circus\n');
62
           'This House\nIs A Circus\n');