Browse Source

Disabled implicit casts and dynamic; fixed analysis issues

Anatoly Pulyaevskiy 6 years ago
parent
commit
16f1af18ac

+ 5
- 4
packages/notus/analysis_options.yaml View File

@@ -1,11 +1,12 @@
1 1
 analyzer:
2
-  language:
3
-    enableSuperMixins: true
4
-
2
+  strong-mode:
3
+    implicit-casts: false
4
+    implicit-dynamic: false
5
+    
5 6
 # Lint rules and documentation, see http://dart-lang.github.io/linter/lints
6 7
 linter:
7 8
   rules:
8
-    # - avoid_init_to_null
9
+    - avoid_init_to_null
9 10
     - cancel_subscriptions
10 11
     - close_sinks
11 12
     - directives_ordering

+ 4
- 3
packages/zefyr/analysis_options.yaml View File

@@ -1,11 +1,12 @@
1 1
 analyzer:
2
-  language:
3
-#    enableSuperMixins: true
2
+  strong-mode:
3
+    implicit-casts: false
4
+    implicit-dynamic: false
4 5
 
5 6
 # Lint rules and documentation, see http://dart-lang.github.io/linter/lints
6 7
 linter:
7 8
   rules:
8
-    # - avoid_init_to_null
9
+    - avoid_init_to_null
9 10
     - cancel_subscriptions
10 11
     - close_sinks
11 12
     - directives_ordering

+ 4
- 6
packages/zefyr/lib/src/widgets/editable_text.dart View File

@@ -1,7 +1,6 @@
1 1
 // Copyright (c) 2018, the Zefyr project authors.  Please see the AUTHORS file
2 2
 // for details. All rights reserved. Use of this source code is governed by a
3 3
 // BSD-style license that can be found in the LICENSE file.
4
-import 'package:collection/collection.dart';
5 4
 import 'package:flutter/cupertino.dart';
6 5
 import 'package:flutter/widgets.dart';
7 6
 import 'package:notus/notus.dart';
@@ -10,7 +9,6 @@ import 'code.dart';
10 9
 import 'common.dart';
11 10
 import 'controller.dart';
12 11
 import 'cursor_timer.dart';
13
-import 'editable_box.dart';
14 12
 import 'editor.dart';
15 13
 import 'image.dart';
16 14
 import 'input.dart';
@@ -197,13 +195,13 @@ class _ZefyrEditableTextState extends State<ZefyrEditableText>
197 195
     final BlockNode block = node;
198 196
     final blockStyle = block.style.get(NotusAttribute.block);
199 197
     if (blockStyle == NotusAttribute.block.code) {
200
-      return new ZefyrCode(node: node);
198
+      return new ZefyrCode(node: block);
201 199
     } else if (blockStyle == NotusAttribute.block.bulletList) {
202
-      return new ZefyrList(node: node);
200
+      return new ZefyrList(node: block);
203 201
     } else if (blockStyle == NotusAttribute.block.numberList) {
204
-      return new ZefyrList(node: node);
202
+      return new ZefyrList(node: block);
205 203
     } else if (blockStyle == NotusAttribute.block.quote) {
206
-      return new ZefyrQuote(node: node);
204
+      return new ZefyrQuote(node: block);
207 205
     }
208 206
 
209 207
     throw new UnimplementedError('Block format $blockStyle.');

+ 1
- 1
packages/zefyr/lib/src/widgets/editor.dart View File

@@ -61,7 +61,7 @@ class _ZefyrEditorState extends State<ZefyrEditor> {
61 61
     _toolbarKey = null;
62 62
   }
63 63
 
64
-  Widget buildToolbar(BuildContext) {
64
+  Widget buildToolbar(BuildContext context) {
65 65
     return ZefyrTheme(
66 66
       data: _themeData,
67 67
       child: ZefyrToolbar(

+ 1
- 1
packages/zefyr/lib/src/widgets/image.dart View File

@@ -54,7 +54,7 @@ class ZefyrImage extends StatefulWidget {
54 54
 class _ZefyrImageState extends State<ZefyrImage> {
55 55
   String get imageSource {
56 56
     EmbedAttribute attribute = widget.node.style.get(NotusAttribute.embed);
57
-    return attribute.value['source'];
57
+    return attribute.value['source'] as String;
58 58
   }
59 59
 
60 60
   @override

+ 2
- 2
packages/zefyr/lib/src/widgets/quote.dart View File

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

+ 1
- 1
packages/zefyr/lib/src/widgets/rich_text.dart View File

@@ -43,7 +43,7 @@ class RenderZefyrParagraph extends RenderParagraph
43 43
     implements RenderEditableBox {
44 44
   RenderZefyrParagraph(
45 45
     TextSpan text, {
46
-    @required ContainerNode node,
46
+    @required LineNode node,
47 47
     TextAlign textAlign: TextAlign.start,
48 48
     @required TextDirection textDirection,
49 49
     bool softWrap: true,

+ 1
- 2
packages/zefyr/lib/src/widgets/selection.dart View File

@@ -10,13 +10,12 @@ import 'package:zefyr/util.dart';
10 10
 
11 11
 import 'controller.dart';
12 12
 import 'editable_box.dart';
13
-import 'render_context.dart';
14 13
 import 'scope.dart';
15 14
 
16 15
 RenderEditableBox _getEditableBox(HitTestResult result) {
17 16
   for (var entry in result.path) {
18 17
     if (entry.target is RenderEditableBox) {
19
-      return entry.target;
18
+      return entry.target as RenderEditableBox;
20 19
     }
21 20
   }
22 21
   return null;

+ 4
- 4
packages/zefyr/lib/src/widgets/view.dart View File

@@ -91,13 +91,13 @@ class ZefyrViewState extends State<ZefyrView> {
91 91
     final BlockNode block = node;
92 92
     final blockStyle = block.style.get(NotusAttribute.block);
93 93
     if (blockStyle == NotusAttribute.block.code) {
94
-      return new ZefyrCode(node: node);
94
+      return new ZefyrCode(node: block);
95 95
     } else if (blockStyle == NotusAttribute.block.bulletList) {
96
-      return new ZefyrList(node: node);
96
+      return new ZefyrList(node: block);
97 97
     } else if (blockStyle == NotusAttribute.block.numberList) {
98
-      return new ZefyrList(node: node);
98
+      return new ZefyrList(node: block);
99 99
     } else if (blockStyle == NotusAttribute.block.quote) {
100
-      return new ZefyrQuote(node: node);
100
+      return new ZefyrQuote(node: block);
101 101
     }
102 102
 
103 103
     throw new UnimplementedError('Block format $blockStyle.');

+ 1
- 1
packages/zefyr/test/rendering/render_editable_paragraph_test.dart View File

@@ -24,7 +24,7 @@ void main() {
24 24
       renderContext = new ZefyrRenderContext();
25 25
       p = new RenderZefyrParagraph(
26 26
         text,
27
-        node: doc.root.children.first,
27
+        node: doc.root.children.first as LineNode,
28 28
         textDirection: TextDirection.ltr,
29 29
       );
30 30
     });

+ 2
- 2
packages/zefyr/test/widgets/buttons_test.dart View File

@@ -24,7 +24,7 @@ void main() {
24 24
       expect(bold.value, 'House');
25 25
 
26 26
       await editor.tapButtonWithIcon(Icons.format_bold);
27
-      line = editor.document.root.children.first;
27
+      line = editor.document.root.children.first as LineNode;
28 28
       expect(line.childCount, 1);
29 29
     });
30 30
 
@@ -139,7 +139,7 @@ void main() {
139 139
       await editor.updateSelection(base: 7, extent: 7);
140 140
       await editor.tapButtonWithIcon(Icons.link);
141 141
       await editor.tapButtonWithIcon(Icons.link_off);
142
-      line = editor.document.root.children.first;
142
+      line = editor.document.root.children.first as LineNode;
143 143
       expect(line.childCount, 1);
144 144
     });
145 145
   });

+ 1
- 1
packages/zefyr/test/widgets/editable_text_scope_test.dart View File

@@ -97,7 +97,7 @@ RenderEditableProxyBox createParagraph(ZefyrRenderContext context) {
97 97
   final selection = new TextSelection.collapsed(offset: 0);
98 98
   final selectionColor = Colors.blue;
99 99
   return new RenderEditableProxyBox(
100
-    node: doc.root.children.first,
100
+    node: doc.root.children.first as LineNode,
101 101
     layerLink: link,
102 102
     renderContext: context,
103 103
     showCursor: showCursor,

+ 1
- 1
packages/zefyr/test/widgets/rich_text_test.dart View File

@@ -19,7 +19,7 @@ void main() {
19 19
       widget = new Directionality(
20 20
         textDirection: TextDirection.ltr,
21 21
         child: new ZefyrRichText(
22
-          node: doc.root.children.first,
22
+          node: doc.root.children.first as LineNode,
23 23
           text: text,
24 24
         ),
25 25
       );