diff --git a/analysis_options.yaml b/analysis_options.yaml index 8f139635..306d335b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -12,3 +12,4 @@ linter: - avoid_redundant_argument_values - prefer_const_constructors - prefer_const_constructors_in_immutables + - unnecessary_parenthesis diff --git a/lib/models/documents/document.dart b/lib/models/documents/document.dart index 126ff32b..0ff76faf 100644 --- a/lib/models/documents/document.dart +++ b/lib/models/documents/document.dart @@ -144,11 +144,11 @@ class Document { try { _delta = _delta.compose(delta); } catch (e) { - throw ('_delta compose failed'); + throw '_delta compose failed'; } if (_delta != _root.toDelta()) { - throw ('Compose failed'); + throw 'Compose failed'; } final change = Tuple3(originalDelta, delta, changeSource); _observer.add(change); diff --git a/lib/models/documents/nodes/leaf.dart b/lib/models/documents/nodes/leaf.dart index efb2ccde..6cb9af24 100644 --- a/lib/models/documents/nodes/leaf.dart +++ b/lib/models/documents/nodes/leaf.dart @@ -26,7 +26,7 @@ abstract class Leaf extends Node { @override 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'); super.applyStyle(value); } diff --git a/lib/models/quill_delta.dart b/lib/models/quill_delta.dart index 72d26846..ddccb710 100644 --- a/lib/models/quill_delta.dart +++ b/lib/models/quill_delta.dart @@ -118,7 +118,7 @@ class Operation { bool get isRetain => key == Operation.retainKey; /// 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. bool get isNotPlain => !isPlain; diff --git a/lib/models/rules/rule.dart b/lib/models/rules/rule.dart index 8141aaf3..70a5aa74 100644 --- a/lib/models/rules/rule.dart +++ b/lib/models/rules/rule.dart @@ -67,6 +67,6 @@ class Rules { rethrow; } } - throw ('Apply rules failed'); + throw 'Apply rules failed'; } } diff --git a/lib/utils/color.dart b/lib/utils/color.dart index 4bc1c55a..4e206644 100644 --- a/lib/utils/color.dart +++ b/lib/utils/color.dart @@ -115,7 +115,7 @@ Color stringToColor(String? s) { } if (!s.startsWith('#')) { - throw ('Color code not supported'); + throw 'Color code not supported'; } String hex = s.replaceFirst('#', ''); diff --git a/lib/utils/diff_delta.dart b/lib/utils/diff_delta.dart index 8733c48f..127c2d8b 100644 --- a/lib/utils/diff_delta.dart +++ b/lib/utils/diff_delta.dart @@ -79,11 +79,11 @@ int getPositionDelta(Delta user, Delta actual) { Operation userOperation = userItr.next(length as int); Operation actualOperation = actualItr.next(length); if (userOperation.length != actualOperation.length) { - throw ('userOp ' + + throw 'userOp ' + userOperation.length.toString() + ' does not match ' + ' actualOp ' + - actualOperation.length.toString()); + actualOperation.length.toString(); } if (userOperation.key == actualOperation.key) { continue; diff --git a/lib/widgets/editor.dart b/lib/widgets/editor.dart index 84a4c9d5..5bab5fb4 100644 --- a/lib/widgets/editor.dart +++ b/lib/widgets/editor.dart @@ -371,7 +371,7 @@ class _QuillEditorSelectionGestureDetectorBuilder ); break; default: - throw ('Invalid platform'); + throw 'Invalid platform'; } } @@ -522,7 +522,7 @@ class _QuillEditorSelectionGestureDetectorBuilder Feedback.forLongPress(_state.context); break; default: - throw ('Invalid platform'); + throw 'Invalid platform'; } } } @@ -964,7 +964,7 @@ class RenderEditableContainerBox extends RenderBox targetChild = childAfter(targetChild); } if (targetChild == null) { - throw ('targetChild should not be null'); + throw 'targetChild should not be null'; } return targetChild; } @@ -994,7 +994,7 @@ class RenderEditableContainerBox extends RenderBox dy += child.size.height; child = childAfter(child); } - throw ('No child'); + throw 'No child'; } @override diff --git a/lib/widgets/raw_editor.dart b/lib/widgets/raw_editor.dart index b922f2be..e0774208 100644 --- a/lib/widgets/raw_editor.dart +++ b/lib/widgets/raw_editor.dart @@ -650,7 +650,7 @@ class RawEditorState extends EditorState case 3: return defaultStyles!.h3!.verticalSpacing; default: - throw ('Invalid level $level'); + throw 'Invalid level $level'; } } diff --git a/lib/widgets/text_block.dart b/lib/widgets/text_block.dart index 92b82ae5..7ea5b278 100644 --- a/lib/widgets/text_block.dart +++ b/lib/widgets/text_block.dart @@ -219,7 +219,7 @@ class EditableTextBlock extends StatelessWidget { bottom = defaultStyles.h3!.verticalSpacing.item2; break; default: - throw ('Invalid level $level'); + throw 'Invalid level $level'; } } else { late Tuple2 lineSpacing; @@ -497,7 +497,7 @@ class RenderEditableTextBlock extends RenderEditableContainerBox offset.translate(decorationPadding.left, decorationPadding.top); _painter!.paint(context.canvas, decorationOffset, filledConfiguration); 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) { context.setIsComplexHint(); diff --git a/lib/widgets/text_line.dart b/lib/widgets/text_line.dart index 1b2be8e6..0a9ef94e 100644 --- a/lib/widgets/text_line.dart +++ b/lib/widgets/text_line.dart @@ -552,7 +552,7 @@ class RenderEditableTextLine extends RenderEditableBox { Rect.fromLTWH(0.0, 2.0, cursorWidth, cursorHeight - 4.0); break; default: - throw ('Invalid platform'); + throw 'Invalid platform'; } } @@ -733,7 +733,7 @@ class RenderEditableTextLine extends RenderEditableBox { if (_body != null) { final parentData = _body!.parentData as BoxParentData; final effectiveOffset = offset + parentData.offset; - if ((enableInteractiveSelection) && + if (enableInteractiveSelection && line.getDocumentOffset() <= textSelection.end && textSelection.start <= line.getDocumentOffset() + line.length - 1) { final local = localSelection(line, textSelection, false); @@ -862,7 +862,7 @@ class _TextLineElement extends RenderObjectElement { renderObject.setLeading(child); break; case TextLineSlot.BODY: - renderObject.setBody((child) as RenderContentProxyBox?); + renderObject.setBody(child as RenderContentProxyBox?); break; default: throw UnimplementedError(); diff --git a/lib/widgets/text_selection.dart b/lib/widgets/text_selection.dart index 366c7d0b..8aa29d25 100644 --- a/lib/widgets/text_selection.dart +++ b/lib/widgets/text_selection.dart @@ -104,8 +104,8 @@ class EditorTextSelectionOverlay { Widget _buildHandle( BuildContext context, _TextSelectionHandlePosition position) { - if ((_selection.isCollapsed && - position == _TextSelectionHandlePosition.END)) { + if (_selection.isCollapsed && + position == _TextSelectionHandlePosition.END) { return Container(); } return Visibility( @@ -153,7 +153,7 @@ class EditorTextSelectionOverlay { : const TextPosition(offset: 0); break; default: - throw ('Invalid position'); + throw 'Invalid position'; } selectionDelegate.textEditingValue = value.copyWith(selection: newSelection, composing: TextRange.empty); diff --git a/lib/widgets/toolbar.dart b/lib/widgets/toolbar.dart index 47a490d8..d3440cfa 100644 --- a/lib/widgets/toolbar.dart +++ b/lib/widgets/toolbar.dart @@ -865,9 +865,11 @@ class ClearFormatButton extends StatefulWidget { final QuillController controller; - const ClearFormatButton( - {required this.icon, required this.controller, Key? key,}) - : super(key: key); + const ClearFormatButton({ + required this.icon, + required this.controller, + Key? key, + }) : super(key: key); @override _ClearFormatButtonState createState() => _ClearFormatButtonState();