Browse Source

Merge pull request #145 from memspace/remove-new-keyword

Removed 'new' keyword from zefyr package
Anatoly Pulyaevskiy 5 years ago
parent
commit
faff567440
No account linked to committer's email address

+ 8
- 8
packages/zefyr/lib/src/widgets/buttons.dart View File

82
       );
82
       );
83
     } else {
83
     } else {
84
       assert(_text != null);
84
       assert(_text != null);
85
-      var style = _textStyle ?? new TextStyle();
85
+      var style = _textStyle ?? TextStyle();
86
       style = style.copyWith(color: iconColor);
86
       style = style.copyWith(color: iconColor);
87
       return RawZefyrButton(
87
       return RawZefyrButton(
88
         action: action,
88
         action: action,
89
-        child: new Text(_text, style: style),
89
+        child: Text(_text, style: style),
90
         color: _getColor(editor, toolbarTheme),
90
         color: _getColor(editor, toolbarTheme),
91
         onPressed: _getPressedHandler(editor, toolbar),
91
         onPressed: _getPressedHandler(editor, toolbar),
92
       );
92
       );
155
     Color iconColor,
155
     Color iconColor,
156
     @required this.color,
156
     @required this.color,
157
     @required this.onPressed,
157
     @required this.onPressed,
158
-  })  : child = new Icon(icon, size: size, color: iconColor),
158
+  })  : child = Icon(icon, size: size, color: iconColor),
159
         super();
159
         super();
160
 
160
 
161
   /// Toolbar action associated with this button.
161
   /// Toolbar action associated with this button.
346
   void edit() {
346
   void edit() {
347
     final toolbar = ZefyrToolbar.of(context);
347
     final toolbar = ZefyrToolbar.of(context);
348
     setState(() {
348
     setState(() {
349
-      _inputKey = new UniqueKey();
349
+      _inputKey = UniqueKey();
350
       _inputController.text = getLink('https://');
350
       _inputController.text = getLink('https://');
351
       _inputController.addListener(_handleInputChange);
351
       _inputController.addListener(_handleInputChange);
352
       toolbar.markNeedsRebuild();
352
       toolbar.markNeedsRebuild();
405
   void copyToClipboard() {
405
   void copyToClipboard() {
406
     var link = getLink();
406
     var link = getLink();
407
     assert(link != null);
407
     assert(link != null);
408
-    Clipboard.setData(new ClipboardData(text: link));
408
+    Clipboard.setData(ClipboardData(text: link));
409
   }
409
   }
410
 
410
 
411
   void openInBrowser() async {
411
   void openInBrowser() async {
485
 
485
 
486
   @override
486
   @override
487
   _LinkInputState createState() {
487
   _LinkInputState createState() {
488
-    return new _LinkInputState();
488
+    return _LinkInputState();
489
   }
489
   }
490
 }
490
 }
491
 
491
 
533
       focusNode: _focusNode,
533
       focusNode: _focusNode,
534
       controller: widget.controller,
534
       controller: widget.controller,
535
       autofocus: true,
535
       autofocus: true,
536
-      decoration: new InputDecoration(
536
+      decoration: InputDecoration(
537
         hintText: 'https://',
537
         hintText: 'https://',
538
         filled: true,
538
         filled: true,
539
         fillColor: toolbarTheme.color,
539
         fillColor: toolbarTheme.color,
554
   Widget build(BuildContext context) {
554
   Widget build(BuildContext context) {
555
     final theme = Theme.of(context);
555
     final theme = Theme.of(context);
556
     final toolbarTheme = ZefyrTheme.of(context).toolbarTheme;
556
     final toolbarTheme = ZefyrTheme.of(context).toolbarTheme;
557
-    Widget widget = new ClipRect(
557
+    Widget widget = ClipRect(
558
       child: ListView(
558
       child: ListView(
559
         scrollDirection: Axis.horizontal,
559
         scrollDirection: Axis.horizontal,
560
         children: <Widget>[
560
         children: <Widget>[

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

11
   static const double _kCaretWidth = 1.0; // pixels
11
   static const double _kCaretWidth = 1.0; // pixels
12
 
12
 
13
   static Rect buildPrototype(double lineHeight) {
13
   static Rect buildPrototype(double lineHeight) {
14
-    return new Rect.fromLTWH(
14
+    return Rect.fromLTWH(
15
         0.0, 0.0, _kCaretWidth, lineHeight - _kCaretHeightOffset);
15
         0.0, 0.0, _kCaretWidth, lineHeight - _kCaretHeightOffset);
16
   }
16
   }
17
 
17
 
35
   }
35
   }
36
 
36
 
37
   void paint(Canvas canvas, Offset offset) {
37
   void paint(Canvas canvas, Offset offset) {
38
-    final Paint paint = new Paint()..color = _color;
38
+    final Paint paint = Paint()..color = _color;
39
     final Rect caretRect = _prototype.shift(offset);
39
     final Rect caretRect = _prototype.shift(offset);
40
     canvas.drawRect(caretRect, paint);
40
     canvas.drawRect(caretRect, paint);
41
   }
41
   }

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

23
       items.add(_buildLine(line, theme.blockTheme.code.textStyle));
23
       items.add(_buildLine(line, theme.blockTheme.code.textStyle));
24
     }
24
     }
25
 
25
 
26
-    return new Padding(
26
+    return Padding(
27
       padding: theme.blockTheme.code.padding,
27
       padding: theme.blockTheme.code.padding,
28
-      child: new Container(
28
+      child: Container(
29
         // TODO: make decorations configurable
29
         // TODO: make decorations configurable
30
         decoration: BoxDecoration(
30
         decoration: BoxDecoration(
31
           color: Colors.blueGrey.shade50,
31
           color: Colors.blueGrey.shade50,
32
           borderRadius: BorderRadius.circular(3.0),
32
           borderRadius: BorderRadius.circular(3.0),
33
         ),
33
         ),
34
         padding: const EdgeInsets.all(16.0),
34
         padding: const EdgeInsets.all(16.0),
35
-        child: new Column(
35
+        child: Column(
36
           crossAxisAlignment: CrossAxisAlignment.stretch,
36
           crossAxisAlignment: CrossAxisAlignment.stretch,
37
           children: items,
37
           children: items,
38
         ),
38
         ),
42
 
42
 
43
   Widget _buildLine(Node node, TextStyle style) {
43
   Widget _buildLine(Node node, TextStyle style) {
44
     LineNode line = node;
44
     LineNode line = node;
45
-    return new RawZefyrLine(node: line, style: style);
45
+    return RawZefyrLine(node: line, style: style);
46
   }
46
   }
47
 }
47
 }

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

35
   final EdgeInsets padding;
35
   final EdgeInsets padding;
36
 
36
 
37
   @override
37
   @override
38
-  _RawZefyrLineState createState() => new _RawZefyrLineState();
38
+  _RawZefyrLineState createState() => _RawZefyrLineState();
39
 }
39
 }
40
 
40
 
41
 class _RawZefyrLineState extends State<RawZefyrLine> {
41
 class _RawZefyrLineState extends State<RawZefyrLine> {
42
-  final LayerLink _link = new LayerLink();
42
+  final LayerLink _link = LayerLink();
43
 
43
 
44
   @override
44
   @override
45
   Widget build(BuildContext context) {
45
   Widget build(BuildContext context) {
113
     final List<TextSpan> children = widget.node.children
113
     final List<TextSpan> children = widget.node.children
114
         .map((node) => _segmentToTextSpan(node, theme))
114
         .map((node) => _segmentToTextSpan(node, theme))
115
         .toList(growable: false);
115
         .toList(growable: false);
116
-    return new TextSpan(style: widget.style, children: children);
116
+    return TextSpan(style: widget.style, children: children);
117
   }
117
   }
118
 
118
 
119
   TextSpan _segmentToTextSpan(Node node, ZefyrThemeData theme) {
119
   TextSpan _segmentToTextSpan(Node node, ZefyrThemeData theme) {
120
     final TextNode segment = node;
120
     final TextNode segment = node;
121
     final attrs = segment.style;
121
     final attrs = segment.style;
122
 
122
 
123
-    return new TextSpan(
123
+    return TextSpan(
124
       text: segment.value,
124
       text: segment.value,
125
       style: _getTextStyle(attrs, theme),
125
       style: _getTextStyle(attrs, theme),
126
     );
126
     );
127
   }
127
   }
128
 
128
 
129
   TextStyle _getTextStyle(NotusStyle style, ZefyrThemeData theme) {
129
   TextStyle _getTextStyle(NotusStyle style, ZefyrThemeData theme) {
130
-    TextStyle result = new TextStyle();
130
+    TextStyle result = TextStyle();
131
     if (style.containsSame(NotusAttribute.bold)) {
131
     if (style.containsSame(NotusAttribute.bold)) {
132
       result = result.merge(theme.boldStyle);
132
       result = result.merge(theme.boldStyle);
133
     }
133
     }
149
     } else if (embed.type == EmbedType.image) {
149
     } else if (embed.type == EmbedType.image) {
150
       return ZefyrImage(node: node, delegate: scope.imageDelegate);
150
       return ZefyrImage(node: node, delegate: scope.imageDelegate);
151
     } else {
151
     } else {
152
-      throw new UnimplementedError('Unimplemented embed type ${embed.type}');
152
+      throw UnimplementedError('Unimplemented embed type ${embed.type}');
153
     }
153
     }
154
   }
154
   }
155
 }
155
 }

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

119
       } else {
119
       } else {
120
         // need to transform selection position in case actual delta
120
         // need to transform selection position in case actual delta
121
         // is different from user's version (in deletes and inserts).
121
         // is different from user's version (in deletes and inserts).
122
-        Delta user = new Delta()
122
+        Delta user = Delta()
123
           ..retain(index)
123
           ..retain(index)
124
           ..insert(text)
124
           ..insert(text)
125
           ..delete(length);
125
           ..delete(length);
144
     // the change. This is needed in cases when format operation actually
144
     // the change. This is needed in cases when format operation actually
145
     // inserts data into the document (e.g. embeds).
145
     // inserts data into the document (e.g. embeds).
146
     final base = change.transformPosition(_selection.baseOffset);
146
     final base = change.transformPosition(_selection.baseOffset);
147
-    final extent =
148
-        change.transformPosition(_selection.extentOffset);
147
+    final extent = change.transformPosition(_selection.extentOffset);
149
     final adjustedSelection =
148
     final adjustedSelection =
150
         _selection.copyWith(baseOffset: base, extentOffset: extent);
149
         _selection.copyWith(baseOffset: base, extentOffset: extent);
151
     if (_selection != adjustedSelection) {
150
     if (_selection != adjustedSelection) {
168
   }
167
   }
169
 
168
 
170
   TextEditingValue get plainTextEditingValue {
169
   TextEditingValue get plainTextEditingValue {
171
-    return new TextEditingValue(
170
+    return TextEditingValue(
172
       text: document.toPlainText(),
171
       text: document.toPlainText(),
173
       selection: selection,
172
       selection: selection,
174
-      composing: new TextRange.collapsed(0),
173
+      composing: TextRange.collapsed(0),
175
     );
174
     );
176
   }
175
   }
177
 
176
 

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

33
 
33
 
34
   @override
34
   @override
35
   RenderEditableProxyBox createRenderObject(BuildContext context) {
35
   RenderEditableProxyBox createRenderObject(BuildContext context) {
36
-    return new RenderEditableProxyBox(
36
+    return RenderEditableProxyBox(
37
       node: node,
37
       node: node,
38
       layerLink: layerLink,
38
       layerLink: layerLink,
39
       renderContext: renderContext,
39
       renderContext: renderContext,
238
   @override
238
   @override
239
   bool hitTest(HitTestResult result, {Offset position}) {
239
   bool hitTest(HitTestResult result, {Offset position}) {
240
     if (size.contains(position)) {
240
     if (size.contains(position)) {
241
-      result.add(new BoxHitTestEntry(this, position));
241
+      result.add(BoxHitTestEntry(this, position));
242
       return true;
242
       return true;
243
     }
243
     }
244
     return false;
244
     return false;

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

76
   final EdgeInsets padding;
76
   final EdgeInsets padding;
77
 
77
 
78
   @override
78
   @override
79
-  _ZefyrEditableTextState createState() => new _ZefyrEditableTextState();
79
+  _ZefyrEditableTextState createState() => _ZefyrEditableTextState();
80
 }
80
 }
81
 
81
 
82
 class _ZefyrEditableTextState extends State<ZefyrEditableText>
82
 class _ZefyrEditableTextState extends State<ZefyrEditableText>
160
     _focusNode = widget.focusNode;
160
     _focusNode = widget.focusNode;
161
     super.initState();
161
     super.initState();
162
     _focusAttachment = _focusNode.attach(context);
162
     _focusAttachment = _focusNode.attach(context);
163
-    _input = new InputConnectionController(_handleRemoteValueChange);
163
+    _input = InputConnectionController(_handleRemoteValueChange);
164
     _updateSubscriptions();
164
     _updateSubscriptions();
165
   }
165
   }
166
 
166
 
228
   Widget _defaultChildBuilder(BuildContext context, Node node) {
228
   Widget _defaultChildBuilder(BuildContext context, Node node) {
229
     if (node is LineNode) {
229
     if (node is LineNode) {
230
       if (node.hasEmbed) {
230
       if (node.hasEmbed) {
231
-        return new RawZefyrLine(node: node);
231
+        return RawZefyrLine(node: node);
232
       } else if (node.style.contains(NotusAttribute.heading)) {
232
       } else if (node.style.contains(NotusAttribute.heading)) {
233
-        return new ZefyrHeading(node: node);
233
+        return ZefyrHeading(node: node);
234
       }
234
       }
235
-      return new ZefyrParagraph(node: node);
235
+      return ZefyrParagraph(node: node);
236
     }
236
     }
237
 
237
 
238
     final BlockNode block = node;
238
     final BlockNode block = node;
239
     final blockStyle = block.style.get(NotusAttribute.block);
239
     final blockStyle = block.style.get(NotusAttribute.block);
240
     if (blockStyle == NotusAttribute.block.code) {
240
     if (blockStyle == NotusAttribute.block.code) {
241
-      return new ZefyrCode(node: block);
241
+      return ZefyrCode(node: block);
242
     } else if (blockStyle == NotusAttribute.block.bulletList) {
242
     } else if (blockStyle == NotusAttribute.block.bulletList) {
243
-      return new ZefyrList(node: block);
243
+      return ZefyrList(node: block);
244
     } else if (blockStyle == NotusAttribute.block.numberList) {
244
     } else if (blockStyle == NotusAttribute.block.numberList) {
245
-      return new ZefyrList(node: block);
245
+      return ZefyrList(node: block);
246
     } else if (blockStyle == NotusAttribute.block.quote) {
246
     } else if (blockStyle == NotusAttribute.block.quote) {
247
-      return new ZefyrQuote(node: block);
247
+      return ZefyrQuote(node: block);
248
     }
248
     }
249
 
249
 
250
-    throw new UnimplementedError('Block format $blockStyle.');
250
+    throw UnimplementedError('Block format $blockStyle.');
251
   }
251
   }
252
 
252
 
253
   void _updateSubscriptions([ZefyrEditableText oldWidget]) {
253
   void _updateSubscriptions([ZefyrEditableText oldWidget]) {

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

70
   final EdgeInsets padding;
70
   final EdgeInsets padding;
71
 
71
 
72
   @override
72
   @override
73
-  _ZefyrEditorState createState() => new _ZefyrEditorState();
73
+  _ZefyrEditorState createState() => _ZefyrEditorState();
74
 }
74
 }
75
 
75
 
76
 class _ZefyrEditorState extends State<ZefyrEditor> {
76
 class _ZefyrEditorState extends State<ZefyrEditor> {
178
 
178
 
179
   @override
179
   @override
180
   Widget build(BuildContext context) {
180
   Widget build(BuildContext context) {
181
-    Widget editable = new ZefyrEditableText(
181
+    Widget editable = ZefyrEditableText(
182
       controller: _scope.controller,
182
       controller: _scope.controller,
183
       focusNode: _scope.focusNode,
183
       focusNode: _scope.focusNode,
184
       imageDelegate: _scope.imageDelegate,
184
       imageDelegate: _scope.imageDelegate,

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

75
 
75
 
76
   @override
76
   @override
77
   RenderEditableImage createRenderObject(BuildContext context) {
77
   RenderEditableImage createRenderObject(BuildContext context) {
78
-    return new RenderEditableImage(node: node);
78
+    return RenderEditableImage(node: node);
79
   }
79
   }
80
 
80
 
81
   @override
81
   @override
129
     if (local.isCollapsed) {
129
     if (local.isCollapsed) {
130
       final dx = local.extentOffset == 0 ? _childOffset.dx : size.width;
130
       final dx = local.extentOffset == 0 ? _childOffset.dx : size.width;
131
       return [
131
       return [
132
-        new ui.TextBox.fromLTRBD(
132
+        ui.TextBox.fromLTRBD(
133
             dx, 0.0, dx, size.height - kPaddingBottom, TextDirection.ltr),
133
             dx, 0.0, dx, size.height - kPaddingBottom, TextDirection.ltr),
134
       ];
134
       ];
135
     }
135
     }
136
 
136
 
137
     final rect = _childRect;
137
     final rect = _childRect;
138
     return [
138
     return [
139
-      new ui.TextBox.fromLTRBD(
139
+      ui.TextBox.fromLTRBD(
140
           rect.left, rect.top, rect.left, rect.bottom, TextDirection.ltr),
140
           rect.left, rect.top, rect.left, rect.bottom, TextDirection.ltr),
141
-      new ui.TextBox.fromLTRBD(
141
+      ui.TextBox.fromLTRBD(
142
           rect.right, rect.top, rect.right, rect.bottom, TextDirection.ltr),
142
           rect.right, rect.top, rect.right, rect.bottom, TextDirection.ltr),
143
     ];
143
     ];
144
   }
144
   }
150
     if (offset.dx > size.width / 2) {
150
     if (offset.dx > size.width / 2) {
151
       position++;
151
       position++;
152
     }
152
     }
153
-    return new TextPosition(offset: position);
153
+    return TextPosition(offset: position);
154
   }
154
   }
155
 
155
 
156
   @override
156
   @override
157
   TextRange getWordBoundary(TextPosition position) {
157
   TextRange getWordBoundary(TextPosition position) {
158
     final start = _node.documentOffset;
158
     final start = _node.documentOffset;
159
-    return new TextRange(start: start, end: start + 1);
159
+    return TextRange(start: start, end: start + 1);
160
   }
160
   }
161
 
161
 
162
   @override
162
   @override
169
   @override
169
   @override
170
   Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) {
170
   Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) {
171
     final pos = position.offset - node.documentOffset;
171
     final pos = position.offset - node.documentOffset;
172
-    Offset caretOffset = _childOffset - new Offset(kHorizontalPadding, 0.0);
172
+    Offset caretOffset = _childOffset - Offset(kHorizontalPadding, 0.0);
173
     if (pos == 1) {
173
     if (pos == 1) {
174
-      caretOffset = caretOffset +
175
-          new Offset(_lastChildSize.width + kHorizontalPadding, 0.0);
174
+      caretOffset =
175
+          caretOffset + Offset(_lastChildSize.width + kHorizontalPadding, 0.0);
176
     }
176
     }
177
     return caretOffset;
177
     return caretOffset;
178
   }
178
   }
183
     final localSelection = getLocalSelection(selection);
183
     final localSelection = getLocalSelection(selection);
184
     assert(localSelection != null);
184
     assert(localSelection != null);
185
     if (!localSelection.isCollapsed) {
185
     if (!localSelection.isCollapsed) {
186
-      final Paint paint = new Paint()
186
+      final Paint paint = Paint()
187
         ..color = selectionColor
187
         ..color = selectionColor
188
         ..style = PaintingStyle.stroke
188
         ..style = PaintingStyle.stroke
189
         ..strokeWidth = 3.0;
189
         ..strokeWidth = 3.0;
190
-      final rect = new Rect.fromLTWH(
191
-          0.0, 0.0, _lastChildSize.width, _lastChildSize.height);
190
+      final rect =
191
+          Rect.fromLTWH(0.0, 0.0, _lastChildSize.width, _lastChildSize.height);
192
       context.canvas.drawRect(rect.shift(offset + _childOffset), paint);
192
       context.canvas.drawRect(rect.shift(offset + _childOffset), paint);
193
     }
193
     }
194
   }
194
   }
204
   Offset get _childOffset {
204
   Offset get _childOffset {
205
     final dx = (size.width - _lastChildSize.width) / 2 + kHorizontalPadding;
205
     final dx = (size.width - _lastChildSize.width) / 2 + kHorizontalPadding;
206
     final dy = (size.height - _lastChildSize.height - kPaddingBottom) / 2;
206
     final dy = (size.height - _lastChildSize.height - kPaddingBottom) / 2;
207
-    return new Offset(dx, dy);
207
+    return Offset(dx, dy);
208
   }
208
   }
209
 
209
 
210
   Rect get _childRect {
210
   Rect get _childRect {
211
-    return new Rect.fromLTWH(_childOffset.dx, _childOffset.dy,
212
-        _lastChildSize.width, _lastChildSize.height);
211
+    return Rect.fromLTWH(_childOffset.dx, _childOffset.dy, _lastChildSize.width,
212
+        _lastChildSize.height);
213
   }
213
   }
214
 
214
 
215
   @override
215
   @override
226
       );
226
       );
227
       child.layout(childConstraints, parentUsesSize: true);
227
       child.layout(childConstraints, parentUsesSize: true);
228
       _lastChildSize = child.size;
228
       _lastChildSize = child.size;
229
-      size = new Size(
230
-          constraints.maxWidth, _lastChildSize.height + kPaddingBottom);
229
+      size = Size(constraints.maxWidth, _lastChildSize.height + kPaddingBottom);
231
     } else {
230
     } else {
232
       performResize();
231
       performResize();
233
     }
232
     }

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

37
       _lastKnownRemoteTextEditingValue = value;
37
       _lastKnownRemoteTextEditingValue = value;
38
       _textInputConnection = TextInput.attach(
38
       _textInputConnection = TextInput.attach(
39
         this,
39
         this,
40
-        new TextInputConfiguration(
40
+        TextInputConfiguration(
41
           inputType: TextInputType.multiline,
41
           inputType: TextInputType.multiline,
42
           obscureText: false,
42
           obscureText: false,
43
           autocorrect: true,
43
           autocorrect: true,

+ 5
- 5
packages/zefyr/lib/src/widgets/list.dart View File

31
         : theme.blockTheme.bulletList.padding;
31
         : theme.blockTheme.bulletList.padding;
32
     padding = padding.copyWith(left: theme.indentSize);
32
     padding = padding.copyWith(left: theme.indentSize);
33
 
33
 
34
-    return new Padding(
34
+    return Padding(
35
       padding: padding,
35
       padding: padding,
36
-      child: new Column(children: items),
36
+      child: Column(children: items),
37
     );
37
     );
38
   }
38
   }
39
 
39
 
40
   Widget _buildItem(Node node, int index) {
40
   Widget _buildItem(Node node, int index) {
41
     LineNode line = node;
41
     LineNode line = node;
42
-    return new ZefyrListItem(index: index, node: line);
42
+    return ZefyrListItem(index: index, node: line);
43
   }
43
   }
44
 }
44
 }
45
 
45
 
66
       final headingTheme = ZefyrHeading.themeOf(node, context);
66
       final headingTheme = ZefyrHeading.themeOf(node, context);
67
       textStyle = headingTheme.textStyle;
67
       textStyle = headingTheme.textStyle;
68
       padding = headingTheme.padding;
68
       padding = headingTheme.padding;
69
-      content = new ZefyrHeading(node: node);
69
+      content = ZefyrHeading(node: node);
70
     } else {
70
     } else {
71
       textStyle = theme.paragraphTheme.textStyle;
71
       textStyle = theme.paragraphTheme.textStyle;
72
-      content = new RawZefyrLine(node: node, style: textStyle);
72
+      content = RawZefyrLine(node: node, style: textStyle);
73
     }
73
     }
74
 
74
 
75
     Widget bullet =
75
     Widget bullet =

+ 3
- 3
packages/zefyr/lib/src/widgets/paragraph.dart View File

22
     if (blockStyle != null) {
22
     if (blockStyle != null) {
23
       style = style.merge(blockStyle);
23
       style = style.merge(blockStyle);
24
     }
24
     }
25
-    return new RawZefyrLine(
25
+    return RawZefyrLine(
26
       node: node,
26
       node: node,
27
       style: style,
27
       style: style,
28
       padding: theme.paragraphTheme.padding,
28
       padding: theme.paragraphTheme.padding,
46
     if (blockStyle != null) {
46
     if (blockStyle != null) {
47
       style = style.merge(blockStyle);
47
       style = style.merge(blockStyle);
48
     }
48
     }
49
-    return new RawZefyrLine(
49
+    return RawZefyrLine(
50
       node: node,
50
       node: node,
51
       style: style,
51
       style: style,
52
       padding: theme.padding,
52
       padding: theme.padding,
63
     } else if (style == NotusAttribute.heading.level3) {
63
     } else if (style == NotusAttribute.heading.level3) {
64
       return theme.headingTheme.level3;
64
       return theme.headingTheme.level3;
65
     }
65
     }
66
-    throw new UnimplementedError('Unsupported heading style $style');
66
+    throw UnimplementedError('Unsupported heading style $style');
67
   }
67
   }
68
 }
68
 }

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

23
 
23
 
24
   @override
24
   @override
25
   RenderObject createRenderObject(BuildContext context) {
25
   RenderObject createRenderObject(BuildContext context) {
26
-    return new RenderZefyrParagraph(
26
+    return RenderZefyrParagraph(
27
       text,
27
       text,
28
       node: node,
28
       node: node,
29
       textDirection: Directionality.of(context),
29
       textDirection: Directionality.of(context),
51
     double textScaleFactor: 1.0,
51
     double textScaleFactor: 1.0,
52
     int maxLines,
52
     int maxLines,
53
   })  : _node = node,
53
   })  : _node = node,
54
-        _prototypePainter = new TextPainter(
55
-          text: new TextSpan(text: '.', style: text.style),
54
+        _prototypePainter = TextPainter(
55
+          text: TextSpan(text: '.', style: text.style),
56
           textAlign: textAlign,
56
           textAlign: textAlign,
57
           textDirection: textDirection,
57
           textDirection: textDirection,
58
           textScaleFactor: textScaleFactor,
58
           textScaleFactor: textScaleFactor,
94
   @override
94
   @override
95
   TextPosition getPositionForOffset(Offset offset) {
95
   TextPosition getPositionForOffset(Offset offset) {
96
     final position = super.getPositionForOffset(offset);
96
     final position = super.getPositionForOffset(offset);
97
-    return new TextPosition(
97
+    return TextPosition(
98
       offset: _node.documentOffset + position.offset,
98
       offset: _node.documentOffset + position.offset,
99
       affinity: position.affinity,
99
       affinity: position.affinity,
100
     );
100
     );
102
 
102
 
103
   @override
103
   @override
104
   TextRange getWordBoundary(TextPosition position) {
104
   TextRange getWordBoundary(TextPosition position) {
105
-    final localPosition = new TextPosition(
105
+    final localPosition = TextPosition(
106
       offset: position.offset - _node.documentOffset,
106
       offset: position.offset - _node.documentOffset,
107
       affinity: position.affinity,
107
       affinity: position.affinity,
108
     );
108
     );
109
     final localRange = super.getWordBoundary(localPosition);
109
     final localRange = super.getWordBoundary(localPosition);
110
-    return new TextRange(
110
+    return TextRange(
111
       start: _node.documentOffset + localRange.start,
111
       start: _node.documentOffset + localRange.start,
112
       end: _node.documentOffset + localRange.end,
112
       end: _node.documentOffset + localRange.end,
113
     );
113
     );
115
 
115
 
116
   @override
116
   @override
117
   Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) {
117
   Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) {
118
-    final localPosition = new TextPosition(
118
+    final localPosition = TextPosition(
119
       offset: position.offset - _node.documentOffset,
119
       offset: position.offset - _node.documentOffset,
120
       affinity: position.affinity,
120
       affinity: position.affinity,
121
     );
121
     );
131
       final caret = CursorPainter.buildPrototype(preferredLineHeight);
131
       final caret = CursorPainter.buildPrototype(preferredLineHeight);
132
       final offset = getOffsetForCaret(local.extent, caret);
132
       final offset = getOffsetForCaret(local.extent, caret);
133
       return [
133
       return [
134
-        new ui.TextBox.fromLTRBD(
134
+        ui.TextBox.fromLTRBD(
135
           offset.dx,
135
           offset.dx,
136
           offset.dy,
136
           offset.dy,
137
           offset.dx,
137
           offset.dx,
164
       final box = result.first;
164
       final box = result.first;
165
       final dx = isBaseShifted == -1 ? box.right : box.left;
165
       final dx = isBaseShifted == -1 ? box.right : box.left;
166
       result.removeAt(0);
166
       result.removeAt(0);
167
-      result.insert(0,
168
-          new ui.TextBox.fromLTRBD(dx, box.top, dx, box.bottom, box.direction));
167
+      result.insert(
168
+          0, ui.TextBox.fromLTRBD(dx, box.top, dx, box.bottom, box.direction));
169
     }
169
     }
170
     if (isExtentShifted) {
170
     if (isExtentShifted) {
171
       final box = result.last;
171
       final box = result.last;
172
       result.removeLast;
172
       result.removeLast;
173
-      result.add(new ui.TextBox.fromLTRBD(
173
+      result.add(ui.TextBox.fromLTRBD(
174
           box.left, box.top, box.left, box.bottom, box.direction));
174
           box.left, box.top, box.left, box.bottom, box.direction));
175
     }
175
     }
176
     return result;
176
     return result;
182
 
182
 
183
   @override
183
   @override
184
   void set text(InlineSpan value) {
184
   void set text(InlineSpan value) {
185
-    _prototypePainter.text = new 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;
188
   }
188
   }

+ 16
- 18
packages/zefyr/lib/src/widgets/selection.dart View File

31
   final TextSelectionControls controls;
31
   final TextSelectionControls controls;
32
 
32
 
33
   @override
33
   @override
34
-  _ZefyrSelectionOverlayState createState() =>
35
-      new _ZefyrSelectionOverlayState();
34
+  _ZefyrSelectionOverlayState createState() => _ZefyrSelectionOverlayState();
36
 }
35
 }
37
 
36
 
38
 class _ZefyrSelectionOverlayState extends State<ZefyrSelectionOverlay>
37
 class _ZefyrSelectionOverlayState extends State<ZefyrSelectionOverlay>
164
 
163
 
165
   @override
164
   @override
166
   Widget build(BuildContext context) {
165
   Widget build(BuildContext context) {
167
-    final overlay = new GestureDetector(
166
+    final overlay = GestureDetector(
168
       behavior: HitTestBehavior.translucent,
167
       behavior: HitTestBehavior.translucent,
169
       onTapDown: _handleTapDown,
168
       onTapDown: _handleTapDown,
170
       onTap: _handleTap,
169
       onTap: _handleTap,
171
       onTapCancel: _handleTapCancel,
170
       onTapCancel: _handleTapCancel,
172
       onLongPress: _handleLongPress,
171
       onLongPress: _handleLongPress,
173
-      child: new Stack(
172
+      child: Stack(
174
         fit: StackFit.expand,
173
         fit: StackFit.expand,
175
         children: <Widget>[
174
         children: <Widget>[
176
-          new SelectionHandleDriver(
175
+          SelectionHandleDriver(
177
             position: _SelectionHandlePosition.base,
176
             position: _SelectionHandlePosition.base,
178
             selectionOverlay: this,
177
             selectionOverlay: this,
179
           ),
178
           ),
180
-          new SelectionHandleDriver(
179
+          SelectionHandleDriver(
181
             position: _SelectionHandlePosition.extent,
180
             position: _SelectionHandlePosition.extent,
182
             selectionOverlay: this,
181
             selectionOverlay: this,
183
           ),
182
           ),
184
         ],
183
         ],
185
       ),
184
       ),
186
     );
185
     );
187
-    return new Container(child: overlay);
186
+    return Container(child: overlay);
188
   }
187
   }
189
 
188
 
190
   //
189
   //
241
     assert(_lastTapDownPosition != null);
240
     assert(_lastTapDownPosition != null);
242
     final globalPoint = _lastTapDownPosition;
241
     final globalPoint = _lastTapDownPosition;
243
     _lastTapDownPosition = null;
242
     _lastTapDownPosition = null;
244
-    HitTestResult result = new HitTestResult();
243
+    HitTestResult result = HitTestResult();
245
     WidgetsBinding.instance.hitTest(result, globalPoint);
244
     WidgetsBinding.instance.hitTest(result, globalPoint);
246
 
245
 
247
     RenderEditableProxyBox box = _getEditableBox(result);
246
     RenderEditableProxyBox box = _getEditableBox(result);
252
 
251
 
253
     final localPoint = box.globalToLocal(globalPoint);
252
     final localPoint = box.globalToLocal(globalPoint);
254
     final position = box.getPositionForOffset(localPoint);
253
     final position = box.getPositionForOffset(localPoint);
255
-    final selection = new TextSelection.collapsed(
254
+    final selection = TextSelection.collapsed(
256
       offset: position.offset,
255
       offset: position.offset,
257
       affinity: position.affinity,
256
       affinity: position.affinity,
258
     );
257
     );
272
   void _handleLongPress() {
271
   void _handleLongPress() {
273
     final Offset globalPoint = _longPressPosition;
272
     final Offset globalPoint = _longPressPosition;
274
     _longPressPosition = null;
273
     _longPressPosition = null;
275
-    HitTestResult result = new HitTestResult();
274
+    HitTestResult result = HitTestResult();
276
     WidgetsBinding.instance.hitTest(result, globalPoint);
275
     WidgetsBinding.instance.hitTest(result, globalPoint);
277
     final box = _getEditableBox(result);
276
     final box = _getEditableBox(result);
278
     if (box == null) {
277
     if (box == null) {
281
     final localPoint = box.globalToLocal(globalPoint);
280
     final localPoint = box.globalToLocal(globalPoint);
282
     final position = box.getPositionForOffset(localPoint);
281
     final position = box.getPositionForOffset(localPoint);
283
     final word = box.getWordBoundary(position);
282
     final word = box.getWordBoundary(position);
284
-    final selection = new TextSelection(
283
+    final selection = TextSelection(
285
       baseOffset: word.start,
284
       baseOffset: word.start,
286
       extentOffset: word.end,
285
       extentOffset: word.end,
287
     );
286
     );
315
   final _ZefyrSelectionOverlayState selectionOverlay;
314
   final _ZefyrSelectionOverlayState selectionOverlay;
316
 
315
 
317
   @override
316
   @override
318
-  _SelectionHandleDriverState createState() =>
319
-      new _SelectionHandleDriverState();
317
+  _SelectionHandleDriverState createState() => _SelectionHandleDriverState();
320
 }
318
 }
321
 
319
 
322
 class _SelectionHandleDriverState extends State<SelectionHandleDriver>
320
 class _SelectionHandleDriverState extends State<SelectionHandleDriver>
376
   @override
374
   @override
377
   Widget build(BuildContext context) {
375
   Widget build(BuildContext context) {
378
     if (widget.selectionOverlay.shouldHideControls) {
376
     if (widget.selectionOverlay.shouldHideControls) {
379
-      return new Container();
377
+      return Container();
380
     }
378
     }
381
     final block = _scope.renderContext.boxForTextOffset(documentOffset);
379
     final block = _scope.renderContext.boxForTextOffset(documentOffset);
382
     if (block == null) {
380
     if (block == null) {
543
   final _ZefyrSelectionOverlayState selectionOverlay;
541
   final _ZefyrSelectionOverlayState selectionOverlay;
544
 
542
 
545
   @override
543
   @override
546
-  _SelectionToolbarState createState() => new _SelectionToolbarState();
544
+  _SelectionToolbarState createState() => _SelectionToolbarState();
547
 }
545
 }
548
 
546
 
549
 class _SelectionToolbarState extends State<_SelectionToolbar> {
547
 class _SelectionToolbarState extends State<_SelectionToolbar> {
565
     }
563
     }
566
     final boxes = block.getEndpointsForSelection(selection);
564
     final boxes = block.getEndpointsForSelection(selection);
567
     // Find the horizontal midpoint, just above the selected text.
565
     // Find the horizontal midpoint, just above the selected text.
568
-    Offset midpoint = new Offset(
566
+    Offset midpoint = Offset(
569
       (boxes.length == 1)
567
       (boxes.length == 1)
570
           ? (boxes[0].start + boxes[0].end) / 2.0
568
           ? (boxes[0].start + boxes[0].end) / 2.0
571
           : (boxes[0].start + boxes[1].start) / 2.0,
569
           : (boxes[0].start + boxes[1].start) / 2.0,
588
       ];
586
       ];
589
     }
587
     }
590
 
588
 
591
-    final Rect editingRegion = new Rect.fromPoints(
589
+    final Rect editingRegion = Rect.fromPoints(
592
       block.localToGlobal(Offset.zero),
590
       block.localToGlobal(Offset.zero),
593
       block.localToGlobal(block.size.bottomRight(Offset.zero)),
591
       block.localToGlobal(block.size.bottomRight(Offset.zero)),
594
     );
592
     );
600
         midpoint,
598
         midpoint,
601
         endpoints,
599
         endpoints,
602
         widget.selectionOverlay);
600
         widget.selectionOverlay);
603
-    return new CompositedTransformFollower(
601
+    return CompositedTransformFollower(
604
       link: block.layerLink,
602
       link: block.layerLink,
605
       showWhenUnlinked: false,
603
       showWhenUnlinked: false,
606
       offset: -editingRegion.topLeft,
604
       offset: -editingRegion.topLeft,

+ 9
- 9
packages/zefyr/lib/src/widgets/toolbar.dart View File

88
     } else if (autoImplyTrailing) {
88
     } else if (autoImplyTrailing) {
89
       children.add(toolbar.buildButton(context, ZefyrToolbarAction.close));
89
       children.add(toolbar.buildButton(context, ZefyrToolbarAction.close));
90
     }
90
     }
91
-    return new Container(
91
+    return Container(
92
       constraints: constraints,
92
       constraints: constraints,
93
       child: Material(color: theme.color, child: Row(children: children)),
93
       child: Material(color: theme.color, child: Row(children: children)),
94
     );
94
     );
122
   ZefyrToolbarState createState() => ZefyrToolbarState();
122
   ZefyrToolbarState createState() => ZefyrToolbarState();
123
 
123
 
124
   @override
124
   @override
125
-  ui.Size get preferredSize => new Size.fromHeight(ZefyrToolbar.kToolbarHeight);
125
+  ui.Size get preferredSize => Size.fromHeight(ZefyrToolbar.kToolbarHeight);
126
 }
126
 }
127
 
127
 
128
 class _ZefyrToolbarScope extends InheritedWidget {
128
 class _ZefyrToolbarScope extends InheritedWidget {
165
 
165
 
166
   Future<void> showOverlay(WidgetBuilder builder) async {
166
   Future<void> showOverlay(WidgetBuilder builder) async {
167
     assert(_overlayBuilder == null);
167
     assert(_overlayBuilder == null);
168
-    final completer = new Completer<void>();
168
+    final completer = Completer<void>();
169
     setState(() {
169
     setState(() {
170
       _overlayBuilder = builder;
170
       _overlayBuilder = builder;
171
       _overlayCompleter = completer;
171
       _overlayCompleter = completer;
192
   @override
192
   @override
193
   void initState() {
193
   void initState() {
194
     super.initState();
194
     super.initState();
195
-    _delegate = widget.delegate ?? new _DefaultZefyrToolbarDelegate();
196
-    _overlayAnimation = new AnimationController(
197
-        vsync: this, duration: Duration(milliseconds: 100));
195
+    _delegate = widget.delegate ?? _DefaultZefyrToolbarDelegate();
196
+    _overlayAnimation =
197
+        AnimationController(vsync: this, duration: Duration(milliseconds: 100));
198
     _selection = editor.selection;
198
     _selection = editor.selection;
199
   }
199
   }
200
 
200
 
202
   void didUpdateWidget(ZefyrToolbar oldWidget) {
202
   void didUpdateWidget(ZefyrToolbar oldWidget) {
203
     super.didUpdateWidget(oldWidget);
203
     super.didUpdateWidget(oldWidget);
204
     if (widget.delegate != oldWidget.delegate) {
204
     if (widget.delegate != oldWidget.delegate) {
205
-      _delegate = widget.delegate ?? new _DefaultZefyrToolbarDelegate();
205
+      _delegate = widget.delegate ?? _DefaultZefyrToolbarDelegate();
206
     }
206
     }
207
   }
207
   }
208
 
208
 
227
     layers.add(toolbar);
227
     layers.add(toolbar);
228
 
228
 
229
     if (hasOverlay) {
229
     if (hasOverlay) {
230
-      Widget widget = new Builder(builder: _overlayBuilder);
230
+      Widget widget = Builder(builder: _overlayBuilder);
231
       assert(widget != null);
231
       assert(widget != null);
232
       final overlay = FadeTransition(
232
       final overlay = FadeTransition(
233
         key: _overlayKey,
233
         key: _overlayKey,
275
 }
275
 }
276
 
276
 
277
 class _ZefyrButtonListState extends State<ZefyrButtonList> {
277
 class _ZefyrButtonListState extends State<ZefyrButtonList> {
278
-  final ScrollController _controller = new ScrollController();
278
+  final ScrollController _controller = ScrollController();
279
   bool _showLeftArrow = false;
279
   bool _showLeftArrow = false;
280
   bool _showRightArrow = false;
280
   bool _showRightArrow = false;
281
 
281
 

+ 3
- 3
packages/zefyr/lib/util.dart View File

12
 export 'src/fast_diff.dart';
12
 export 'src/fast_diff.dart';
13
 
13
 
14
 int getPositionDelta(Delta user, Delta actual) {
14
 int getPositionDelta(Delta user, Delta actual) {
15
-  final userIter = new DeltaIterator(user);
16
-  final actualIter = new DeltaIterator(actual);
15
+  final userIter = DeltaIterator(user);
16
+  final actualIter = DeltaIterator(actual);
17
   int diff = 0;
17
   int diff = 0;
18
   while (userIter.hasNext || actualIter.hasNext) {
18
   while (userIter.hasNext || actualIter.hasNext) {
19
     num length = math.min(userIter.peekLength(), actualIter.peekLength());
19
     num length = math.min(userIter.peekLength(), actualIter.peekLength());
26
     } else if (userOp.isDelete && actualOp.isRetain) {
26
     } else if (userOp.isDelete && actualOp.isRetain) {
27
       diff += userOp.length;
27
       diff += userOp.length;
28
     } else if (userOp.isRetain && actualOp.isInsert) {
28
     } else if (userOp.isRetain && actualOp.isInsert) {
29
-      if (actualOp.data.startsWith('\n') ) {
29
+      if (actualOp.data.startsWith('\n')) {
30
         // At this point user input reached its end (retain). If a heuristic
30
         // At this point user input reached its end (retain). If a heuristic
31
         // rule inserts a new line we should keep cursor on it's original position.
31
         // rule inserts a new line we should keep cursor on it's original position.
32
         continue;
32
         continue;