Remove unnecessary parenthesis (#118)

pull/120/head
Till Friebe 4 years ago committed by GitHub
parent dfeae914b1
commit 4c16af4420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      analysis_options.yaml
  2. 4
      lib/models/documents/document.dart
  3. 2
      lib/models/documents/nodes/leaf.dart
  4. 2
      lib/models/quill_delta.dart
  5. 2
      lib/models/rules/rule.dart
  6. 2
      lib/utils/color.dart
  7. 4
      lib/utils/diff_delta.dart
  8. 8
      lib/widgets/editor.dart
  9. 2
      lib/widgets/raw_editor.dart
  10. 4
      lib/widgets/text_block.dart
  11. 6
      lib/widgets/text_line.dart
  12. 6
      lib/widgets/text_selection.dart
  13. 8
      lib/widgets/toolbar.dart

@ -12,3 +12,4 @@ linter:
- avoid_redundant_argument_values - avoid_redundant_argument_values
- prefer_const_constructors - prefer_const_constructors
- prefer_const_constructors_in_immutables - prefer_const_constructors_in_immutables
- unnecessary_parenthesis

@ -144,11 +144,11 @@ class Document {
try { try {
_delta = _delta.compose(delta); _delta = _delta.compose(delta);
} catch (e) { } catch (e) {
throw ('_delta compose failed'); throw '_delta compose failed';
} }
if (_delta != _root.toDelta()) { if (_delta != _root.toDelta()) {
throw ('Compose failed'); throw 'Compose failed';
} }
final change = Tuple3(originalDelta, delta, changeSource); final change = Tuple3(originalDelta, delta, changeSource);
_observer.add(change); _observer.add(change);

@ -26,7 +26,7 @@ abstract class Leaf extends Node {
@override @override
void applyStyle(Style value) { void applyStyle(Style value) {
assert((value.isInline || value.isIgnored || value.isEmpty), assert(value.isInline || value.isIgnored || value.isEmpty,
'Unable to apply Style to leaf: $value'); 'Unable to apply Style to leaf: $value');
super.applyStyle(value); super.applyStyle(value);
} }

@ -118,7 +118,7 @@ class Operation {
bool get isRetain => key == Operation.retainKey; bool get isRetain => key == Operation.retainKey;
/// Returns `true` if this operation has no attributes, e.g. is plain text. /// Returns `true` if this operation has no attributes, e.g. is plain text.
bool get isPlain => (_attributes == null || _attributes!.isEmpty); bool get isPlain => _attributes == null || _attributes!.isEmpty;
/// Returns `true` if this operation sets at least one attribute. /// Returns `true` if this operation sets at least one attribute.
bool get isNotPlain => !isPlain; bool get isNotPlain => !isPlain;

@ -67,6 +67,6 @@ class Rules {
rethrow; rethrow;
} }
} }
throw ('Apply rules failed'); throw 'Apply rules failed';
} }
} }

@ -115,7 +115,7 @@ Color stringToColor(String? s) {
} }
if (!s.startsWith('#')) { if (!s.startsWith('#')) {
throw ('Color code not supported'); throw 'Color code not supported';
} }
String hex = s.replaceFirst('#', ''); String hex = s.replaceFirst('#', '');

@ -79,11 +79,11 @@ int getPositionDelta(Delta user, Delta actual) {
Operation userOperation = userItr.next(length as int); Operation userOperation = userItr.next(length as int);
Operation actualOperation = actualItr.next(length); Operation actualOperation = actualItr.next(length);
if (userOperation.length != actualOperation.length) { if (userOperation.length != actualOperation.length) {
throw ('userOp ' + throw 'userOp ' +
userOperation.length.toString() + userOperation.length.toString() +
' does not match ' + ' does not match ' +
' actualOp ' + ' actualOp ' +
actualOperation.length.toString()); actualOperation.length.toString();
} }
if (userOperation.key == actualOperation.key) { if (userOperation.key == actualOperation.key) {
continue; continue;

@ -371,7 +371,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
); );
break; break;
default: default:
throw ('Invalid platform'); throw 'Invalid platform';
} }
} }
@ -522,7 +522,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
Feedback.forLongPress(_state.context); Feedback.forLongPress(_state.context);
break; break;
default: default:
throw ('Invalid platform'); throw 'Invalid platform';
} }
} }
} }
@ -964,7 +964,7 @@ class RenderEditableContainerBox extends RenderBox
targetChild = childAfter(targetChild); targetChild = childAfter(targetChild);
} }
if (targetChild == null) { if (targetChild == null) {
throw ('targetChild should not be null'); throw 'targetChild should not be null';
} }
return targetChild; return targetChild;
} }
@ -994,7 +994,7 @@ class RenderEditableContainerBox extends RenderBox
dy += child.size.height; dy += child.size.height;
child = childAfter(child); child = childAfter(child);
} }
throw ('No child'); throw 'No child';
} }
@override @override

@ -650,7 +650,7 @@ class RawEditorState extends EditorState
case 3: case 3:
return defaultStyles!.h3!.verticalSpacing; return defaultStyles!.h3!.verticalSpacing;
default: default:
throw ('Invalid level $level'); throw 'Invalid level $level';
} }
} }

@ -219,7 +219,7 @@ class EditableTextBlock extends StatelessWidget {
bottom = defaultStyles.h3!.verticalSpacing.item2; bottom = defaultStyles.h3!.verticalSpacing.item2;
break; break;
default: default:
throw ('Invalid level $level'); throw 'Invalid level $level';
} }
} else { } else {
late Tuple2 lineSpacing; late Tuple2 lineSpacing;
@ -497,7 +497,7 @@ class RenderEditableTextBlock extends RenderEditableContainerBox
offset.translate(decorationPadding.left, decorationPadding.top); offset.translate(decorationPadding.left, decorationPadding.top);
_painter!.paint(context.canvas, decorationOffset, filledConfiguration); _painter!.paint(context.canvas, decorationOffset, filledConfiguration);
if (debugSaveCount != context.canvas.getSaveCount()) { if (debugSaveCount != context.canvas.getSaveCount()) {
throw ('${_decoration.runtimeType} painter had mismatching save and restore calls.'); throw '${_decoration.runtimeType} painter had mismatching save and restore calls.';
} }
if (decoration.isComplex) { if (decoration.isComplex) {
context.setIsComplexHint(); context.setIsComplexHint();

@ -552,7 +552,7 @@ class RenderEditableTextLine extends RenderEditableBox {
Rect.fromLTWH(0.0, 2.0, cursorWidth, cursorHeight - 4.0); Rect.fromLTWH(0.0, 2.0, cursorWidth, cursorHeight - 4.0);
break; break;
default: default:
throw ('Invalid platform'); throw 'Invalid platform';
} }
} }
@ -733,7 +733,7 @@ class RenderEditableTextLine extends RenderEditableBox {
if (_body != null) { if (_body != null) {
final parentData = _body!.parentData as BoxParentData; final parentData = _body!.parentData as BoxParentData;
final effectiveOffset = offset + parentData.offset; final effectiveOffset = offset + parentData.offset;
if ((enableInteractiveSelection) && if (enableInteractiveSelection &&
line.getDocumentOffset() <= textSelection.end && line.getDocumentOffset() <= textSelection.end &&
textSelection.start <= line.getDocumentOffset() + line.length - 1) { textSelection.start <= line.getDocumentOffset() + line.length - 1) {
final local = localSelection(line, textSelection, false); final local = localSelection(line, textSelection, false);
@ -862,7 +862,7 @@ class _TextLineElement extends RenderObjectElement {
renderObject.setLeading(child); renderObject.setLeading(child);
break; break;
case TextLineSlot.BODY: case TextLineSlot.BODY:
renderObject.setBody((child) as RenderContentProxyBox?); renderObject.setBody(child as RenderContentProxyBox?);
break; break;
default: default:
throw UnimplementedError(); throw UnimplementedError();

@ -104,8 +104,8 @@ class EditorTextSelectionOverlay {
Widget _buildHandle( Widget _buildHandle(
BuildContext context, _TextSelectionHandlePosition position) { BuildContext context, _TextSelectionHandlePosition position) {
if ((_selection.isCollapsed && if (_selection.isCollapsed &&
position == _TextSelectionHandlePosition.END)) { position == _TextSelectionHandlePosition.END) {
return Container(); return Container();
} }
return Visibility( return Visibility(
@ -153,7 +153,7 @@ class EditorTextSelectionOverlay {
: const TextPosition(offset: 0); : const TextPosition(offset: 0);
break; break;
default: default:
throw ('Invalid position'); throw 'Invalid position';
} }
selectionDelegate.textEditingValue = selectionDelegate.textEditingValue =
value.copyWith(selection: newSelection, composing: TextRange.empty); value.copyWith(selection: newSelection, composing: TextRange.empty);

@ -865,9 +865,11 @@ class ClearFormatButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
const ClearFormatButton( const ClearFormatButton({
{required this.icon, required this.controller, Key? key,}) required this.icon,
: super(key: key); required this.controller,
Key? key,
}) : super(key: key);
@override @override
_ClearFormatButtonState createState() => _ClearFormatButtonState(); _ClearFormatButtonState createState() => _ClearFormatButtonState();

Loading…
Cancel
Save