diff --git a/analysis_options.yaml b/analysis_options.yaml index eac60d7e..a7b7b075 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -24,3 +24,4 @@ linter: - prefer_relative_imports - prefer_single_quotes - unnecessary_parenthesis + - avoid_types_on_closure_parameters diff --git a/lib/models/documents/style.dart b/lib/models/documents/style.dart index 37f6a0b9..f8a8ee74 100644 --- a/lib/models/documents/style.dart +++ b/lib/models/documents/style.dart @@ -16,7 +16,7 @@ class Style { return Style(); } - final result = attributes.map((String key, dynamic value) { + final result = attributes.map((key, dynamic value) { final attr = Attribute.fromKeyValue(key, value); return MapEntry(key, attr); }); @@ -25,7 +25,7 @@ class Style { Map? toJson() => _attributes.isEmpty ? null - : _attributes.map((String _, Attribute attribute) => + : _attributes.map((_, attribute) => MapEntry(attribute.key, attribute.value)); Iterable get keys => _attributes.keys; diff --git a/lib/models/rules/delete.dart b/lib/models/rules/delete.dart index 60cee64d..def2e8c7 100644 --- a/lib/models/rules/delete.dart +++ b/lib/models/rules/delete.dart @@ -60,8 +60,8 @@ class PreserveLineStyleOnMergeRule extends DeleteRule { var attributes = op.attributes == null ? null - : op.attributes!.map((String key, dynamic value) => - MapEntry(key, null)); + : op.attributes!.map( + (key, dynamic value) => MapEntry(key, null)); if (isNotPlain) { attributes ??= {}; diff --git a/lib/widgets/editor.dart b/lib/widgets/editor.dart index c3f24d98..f1faaec6 100644 --- a/lib/widgets/editor.dart +++ b/lib/widgets/editor.dart @@ -1019,7 +1019,7 @@ class RenderEditableContainerBox extends RenderBox @override double computeMinIntrinsicWidth(double height) { _resolvePadding(); - return _getIntrinsicCrossAxis((RenderBox child) { + return _getIntrinsicCrossAxis((child) { final childHeight = math.max( 0.0, height - _resolvedPadding!.top + _resolvedPadding!.bottom); return child.getMinIntrinsicWidth(childHeight) + @@ -1031,7 +1031,7 @@ class RenderEditableContainerBox extends RenderBox @override double computeMaxIntrinsicWidth(double height) { _resolvePadding(); - return _getIntrinsicCrossAxis((RenderBox child) { + return _getIntrinsicCrossAxis((child) { final childHeight = math.max( 0.0, height - _resolvedPadding!.top + _resolvedPadding!.bottom); return child.getMaxIntrinsicWidth(childHeight) + @@ -1043,7 +1043,7 @@ class RenderEditableContainerBox extends RenderBox @override double computeMinIntrinsicHeight(double width) { _resolvePadding(); - return _getIntrinsicMainAxis((RenderBox child) { + return _getIntrinsicMainAxis((child) { final childWidth = math.max( 0.0, width - _resolvedPadding!.left + _resolvedPadding!.right); return child.getMinIntrinsicHeight(childWidth) + @@ -1055,7 +1055,7 @@ class RenderEditableContainerBox extends RenderBox @override double computeMaxIntrinsicHeight(double width) { _resolvePadding(); - return _getIntrinsicMainAxis((RenderBox child) { + return _getIntrinsicMainAxis((child) { final childWidth = math.max( 0.0, width - _resolvedPadding!.left + _resolvedPadding!.right); return child.getMaxIntrinsicHeight(childWidth) + diff --git a/lib/widgets/raw_editor.dart b/lib/widgets/raw_editor.dart index 8fc9babd..9747901f 100644 --- a/lib/widgets/raw_editor.dart +++ b/lib/widgets/raw_editor.dart @@ -328,7 +328,7 @@ class RawEditorState extends EditorState } var count = 0; - final remain = string.characters.skipWhile((String currentString) { + final remain = string.characters.skipWhile((currentString) { if (count <= index) { count += currentString.length; return true; @@ -698,7 +698,7 @@ class RawEditorState extends EditorState _keyboardVisibilityController = KeyboardVisibilityController(); _keyboardVisible = _keyboardVisibilityController!.isVisible; _keyboardVisibilitySubscription = - _keyboardVisibilityController?.onChange.listen((bool visible) { + _keyboardVisibilityController?.onChange.listen((visible) { _keyboardVisible = visible; if (visible) { _onChangeTextEditingValue(); @@ -911,7 +911,7 @@ class RawEditorState extends EditorState } SchedulerBinding.instance!.addPostFrameCallback( - (Duration _) => _updateOrDisposeSelectionOverlayIfNeeded()); + (_) => _updateOrDisposeSelectionOverlayIfNeeded()); if (mounted) { setState(() { // Use widget.controller.value in build() @@ -982,7 +982,7 @@ class RawEditorState extends EditorState } _showCaretOnScreenScheduled = true; - SchedulerBinding.instance!.addPostFrameCallback((Duration _) { + SchedulerBinding.instance!.addPostFrameCallback((_) { _showCaretOnScreenScheduled = false; final viewport = RenderAbstractViewport.of(getRenderEditor())!; diff --git a/lib/widgets/text_selection.dart b/lib/widgets/text_selection.dart index cf963d9a..c113faeb 100644 --- a/lib/widgets/text_selection.dart +++ b/lib/widgets/text_selection.dart @@ -111,7 +111,7 @@ class EditorTextSelectionOverlay { return Visibility( visible: handlesVisible, child: _TextSelectionHandleOverlay( - onSelectionHandleChanged: (TextSelection? newSelection) { + onSelectionHandleChanged: (newSelection) { _handleSelectionHandleChanged(newSelection, position); }, onSelectionHandleTapped: onSelectionHandleTapped, @@ -231,10 +231,10 @@ class EditorTextSelectionOverlay { assert(_handles == null); _handles = [ OverlayEntry( - builder: (BuildContext context) => + builder: (context) => _buildHandle(context, _TextSelectionHandlePosition.START)), OverlayEntry( - builder: (BuildContext context) => + builder: (context) => _buildHandle(context, _TextSelectionHandlePosition.END)), ]; @@ -659,7 +659,7 @@ class _EditorTextSelectionGestureDetectorState gestures[TapGestureRecognizer] = GestureRecognizerFactoryWithHandlers( () => TapGestureRecognizer(debugOwner: this), - (TapGestureRecognizer instance) { + (instance) { instance ..onTapDown = _handleTapDown ..onTapUp = _handleTapUp @@ -674,7 +674,7 @@ class _EditorTextSelectionGestureDetectorState GestureRecognizerFactoryWithHandlers( () => LongPressGestureRecognizer( debugOwner: this, kind: PointerDeviceKind.touch), - (LongPressGestureRecognizer instance) { + (instance) { instance ..onLongPressStart = _handleLongPressStart ..onLongPressMoveUpdate = _handleLongPressMoveUpdate @@ -690,7 +690,7 @@ class _EditorTextSelectionGestureDetectorState GestureRecognizerFactoryWithHandlers( () => HorizontalDragGestureRecognizer( debugOwner: this, kind: PointerDeviceKind.mouse), - (HorizontalDragGestureRecognizer instance) { + (instance) { instance ..dragStartBehavior = DragStartBehavior.down ..onStart = _handleDragStart @@ -704,7 +704,7 @@ class _EditorTextSelectionGestureDetectorState gestures[ForcePressGestureRecognizer] = GestureRecognizerFactoryWithHandlers( () => ForcePressGestureRecognizer(debugOwner: this), - (ForcePressGestureRecognizer instance) { + (instance) { instance ..onStart = widget.onForcePressStart != null ? _forcePressStarted : null diff --git a/lib/widgets/toolbar.dart b/lib/widgets/toolbar.dart index 0941760f..9348c3af 100644 --- a/lib/widgets/toolbar.dart +++ b/lib/widgets/toolbar.dart @@ -1251,7 +1251,7 @@ class _QuillDropdownButtonState extends State> { // widget.shape ?? popupMenuTheme.shape, color: popupMenuTheme.color, // widget.color ?? popupMenuTheme.color, // captureInheritedThemes: widget.captureInheritedThemes, - ).then((T? newValue) { + ).then((newValue) { if (!mounted) return null; if (newValue == null) { // if (widget.onCanceled != null) widget.onCanceled();