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

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

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

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

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

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

61
     _toolbarKey = null;
61
     _toolbarKey = null;
62
   }
62
   }
63
 
63
 
64
-  Widget buildToolbar(BuildContext) {
64
+  Widget buildToolbar(BuildContext context) {
65
     return ZefyrTheme(
65
     return ZefyrTheme(
66
       data: _themeData,
66
       data: _themeData,
67
       child: ZefyrToolbar(
67
       child: ZefyrToolbar(

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

54
 class _ZefyrImageState extends State<ZefyrImage> {
54
 class _ZefyrImageState extends State<ZefyrImage> {
55
   String get imageSource {
55
   String get imageSource {
56
     EmbedAttribute attribute = widget.node.style.get(NotusAttribute.embed);
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
   @override
60
   @override

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

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: node, blockStyle: blockStyle);
39
+      content = new ZefyrHeading(node: line, blockStyle: blockStyle);
40
     } else {
40
     } else {
41
-      content = new ZefyrParagraph(node: node, blockStyle: blockStyle);
41
+      content = new 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)]);

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

43
     implements RenderEditableBox {
43
     implements RenderEditableBox {
44
   RenderZefyrParagraph(
44
   RenderZefyrParagraph(
45
     TextSpan text, {
45
     TextSpan text, {
46
-    @required ContainerNode 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,
49
     bool softWrap: true,

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

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

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

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

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

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

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

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

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

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

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

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