Avoid types on closure parameters

Annotating types for function expression parameters is usually
unnecessary because the parameter types can almost always be
inferred from the context, thus making the practice redundant.
pull/145/head
Till Friebe 4 years ago
parent b47d22856b
commit 6c31fb1bc3
  1. 1
      analysis_options.yaml
  2. 4
      lib/models/documents/style.dart
  3. 4
      lib/models/rules/delete.dart
  4. 8
      lib/widgets/editor.dart
  5. 8
      lib/widgets/raw_editor.dart
  6. 14
      lib/widgets/text_selection.dart
  7. 2
      lib/widgets/toolbar.dart

@ -24,3 +24,4 @@ linter:
- prefer_relative_imports - prefer_relative_imports
- prefer_single_quotes - prefer_single_quotes
- unnecessary_parenthesis - unnecessary_parenthesis
- avoid_types_on_closure_parameters

@ -16,7 +16,7 @@ class Style {
return Style(); return Style();
} }
final result = attributes.map((String key, dynamic value) { final result = attributes.map((key, dynamic value) {
final attr = Attribute.fromKeyValue(key, value); final attr = Attribute.fromKeyValue(key, value);
return MapEntry<String, Attribute>(key, attr); return MapEntry<String, Attribute>(key, attr);
}); });
@ -25,7 +25,7 @@ class Style {
Map<String, dynamic>? toJson() => _attributes.isEmpty Map<String, dynamic>? toJson() => _attributes.isEmpty
? null ? null
: _attributes.map<String, dynamic>((String _, Attribute attribute) => : _attributes.map<String, dynamic>((_, attribute) =>
MapEntry<String, dynamic>(attribute.key, attribute.value)); MapEntry<String, dynamic>(attribute.key, attribute.value));
Iterable<String> get keys => _attributes.keys; Iterable<String> get keys => _attributes.keys;

@ -60,8 +60,8 @@ class PreserveLineStyleOnMergeRule extends DeleteRule {
var attributes = op.attributes == null var attributes = op.attributes == null
? null ? null
: op.attributes!.map<String, dynamic>((String key, dynamic value) => : op.attributes!.map<String, dynamic>(
MapEntry<String, dynamic>(key, null)); (key, dynamic value) => MapEntry<String, dynamic>(key, null));
if (isNotPlain) { if (isNotPlain) {
attributes ??= <String, dynamic>{}; attributes ??= <String, dynamic>{};

@ -1019,7 +1019,7 @@ class RenderEditableContainerBox extends RenderBox
@override @override
double computeMinIntrinsicWidth(double height) { double computeMinIntrinsicWidth(double height) {
_resolvePadding(); _resolvePadding();
return _getIntrinsicCrossAxis((RenderBox child) { return _getIntrinsicCrossAxis((child) {
final childHeight = math.max( final childHeight = math.max(
0.0, height - _resolvedPadding!.top + _resolvedPadding!.bottom); 0.0, height - _resolvedPadding!.top + _resolvedPadding!.bottom);
return child.getMinIntrinsicWidth(childHeight) + return child.getMinIntrinsicWidth(childHeight) +
@ -1031,7 +1031,7 @@ class RenderEditableContainerBox extends RenderBox
@override @override
double computeMaxIntrinsicWidth(double height) { double computeMaxIntrinsicWidth(double height) {
_resolvePadding(); _resolvePadding();
return _getIntrinsicCrossAxis((RenderBox child) { return _getIntrinsicCrossAxis((child) {
final childHeight = math.max( final childHeight = math.max(
0.0, height - _resolvedPadding!.top + _resolvedPadding!.bottom); 0.0, height - _resolvedPadding!.top + _resolvedPadding!.bottom);
return child.getMaxIntrinsicWidth(childHeight) + return child.getMaxIntrinsicWidth(childHeight) +
@ -1043,7 +1043,7 @@ class RenderEditableContainerBox extends RenderBox
@override @override
double computeMinIntrinsicHeight(double width) { double computeMinIntrinsicHeight(double width) {
_resolvePadding(); _resolvePadding();
return _getIntrinsicMainAxis((RenderBox child) { return _getIntrinsicMainAxis((child) {
final childWidth = math.max( final childWidth = math.max(
0.0, width - _resolvedPadding!.left + _resolvedPadding!.right); 0.0, width - _resolvedPadding!.left + _resolvedPadding!.right);
return child.getMinIntrinsicHeight(childWidth) + return child.getMinIntrinsicHeight(childWidth) +
@ -1055,7 +1055,7 @@ class RenderEditableContainerBox extends RenderBox
@override @override
double computeMaxIntrinsicHeight(double width) { double computeMaxIntrinsicHeight(double width) {
_resolvePadding(); _resolvePadding();
return _getIntrinsicMainAxis((RenderBox child) { return _getIntrinsicMainAxis((child) {
final childWidth = math.max( final childWidth = math.max(
0.0, width - _resolvedPadding!.left + _resolvedPadding!.right); 0.0, width - _resolvedPadding!.left + _resolvedPadding!.right);
return child.getMaxIntrinsicHeight(childWidth) + return child.getMaxIntrinsicHeight(childWidth) +

@ -328,7 +328,7 @@ class RawEditorState extends EditorState
} }
var count = 0; var count = 0;
final remain = string.characters.skipWhile((String currentString) { final remain = string.characters.skipWhile((currentString) {
if (count <= index) { if (count <= index) {
count += currentString.length; count += currentString.length;
return true; return true;
@ -698,7 +698,7 @@ class RawEditorState extends EditorState
_keyboardVisibilityController = KeyboardVisibilityController(); _keyboardVisibilityController = KeyboardVisibilityController();
_keyboardVisible = _keyboardVisibilityController!.isVisible; _keyboardVisible = _keyboardVisibilityController!.isVisible;
_keyboardVisibilitySubscription = _keyboardVisibilitySubscription =
_keyboardVisibilityController?.onChange.listen((bool visible) { _keyboardVisibilityController?.onChange.listen((visible) {
_keyboardVisible = visible; _keyboardVisible = visible;
if (visible) { if (visible) {
_onChangeTextEditingValue(); _onChangeTextEditingValue();
@ -911,7 +911,7 @@ class RawEditorState extends EditorState
} }
SchedulerBinding.instance!.addPostFrameCallback( SchedulerBinding.instance!.addPostFrameCallback(
(Duration _) => _updateOrDisposeSelectionOverlayIfNeeded()); (_) => _updateOrDisposeSelectionOverlayIfNeeded());
if (mounted) { if (mounted) {
setState(() { setState(() {
// Use widget.controller.value in build() // Use widget.controller.value in build()
@ -982,7 +982,7 @@ class RawEditorState extends EditorState
} }
_showCaretOnScreenScheduled = true; _showCaretOnScreenScheduled = true;
SchedulerBinding.instance!.addPostFrameCallback((Duration _) { SchedulerBinding.instance!.addPostFrameCallback((_) {
_showCaretOnScreenScheduled = false; _showCaretOnScreenScheduled = false;
final viewport = RenderAbstractViewport.of(getRenderEditor())!; final viewport = RenderAbstractViewport.of(getRenderEditor())!;

@ -111,7 +111,7 @@ class EditorTextSelectionOverlay {
return Visibility( return Visibility(
visible: handlesVisible, visible: handlesVisible,
child: _TextSelectionHandleOverlay( child: _TextSelectionHandleOverlay(
onSelectionHandleChanged: (TextSelection? newSelection) { onSelectionHandleChanged: (newSelection) {
_handleSelectionHandleChanged(newSelection, position); _handleSelectionHandleChanged(newSelection, position);
}, },
onSelectionHandleTapped: onSelectionHandleTapped, onSelectionHandleTapped: onSelectionHandleTapped,
@ -231,10 +231,10 @@ class EditorTextSelectionOverlay {
assert(_handles == null); assert(_handles == null);
_handles = <OverlayEntry>[ _handles = <OverlayEntry>[
OverlayEntry( OverlayEntry(
builder: (BuildContext context) => builder: (context) =>
_buildHandle(context, _TextSelectionHandlePosition.START)), _buildHandle(context, _TextSelectionHandlePosition.START)),
OverlayEntry( OverlayEntry(
builder: (BuildContext context) => builder: (context) =>
_buildHandle(context, _TextSelectionHandlePosition.END)), _buildHandle(context, _TextSelectionHandlePosition.END)),
]; ];
@ -659,7 +659,7 @@ class _EditorTextSelectionGestureDetectorState
gestures[TapGestureRecognizer] = gestures[TapGestureRecognizer] =
GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>( GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
() => TapGestureRecognizer(debugOwner: this), () => TapGestureRecognizer(debugOwner: this),
(TapGestureRecognizer instance) { (instance) {
instance instance
..onTapDown = _handleTapDown ..onTapDown = _handleTapDown
..onTapUp = _handleTapUp ..onTapUp = _handleTapUp
@ -674,7 +674,7 @@ class _EditorTextSelectionGestureDetectorState
GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>( GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>(
() => LongPressGestureRecognizer( () => LongPressGestureRecognizer(
debugOwner: this, kind: PointerDeviceKind.touch), debugOwner: this, kind: PointerDeviceKind.touch),
(LongPressGestureRecognizer instance) { (instance) {
instance instance
..onLongPressStart = _handleLongPressStart ..onLongPressStart = _handleLongPressStart
..onLongPressMoveUpdate = _handleLongPressMoveUpdate ..onLongPressMoveUpdate = _handleLongPressMoveUpdate
@ -690,7 +690,7 @@ class _EditorTextSelectionGestureDetectorState
GestureRecognizerFactoryWithHandlers<HorizontalDragGestureRecognizer>( GestureRecognizerFactoryWithHandlers<HorizontalDragGestureRecognizer>(
() => HorizontalDragGestureRecognizer( () => HorizontalDragGestureRecognizer(
debugOwner: this, kind: PointerDeviceKind.mouse), debugOwner: this, kind: PointerDeviceKind.mouse),
(HorizontalDragGestureRecognizer instance) { (instance) {
instance instance
..dragStartBehavior = DragStartBehavior.down ..dragStartBehavior = DragStartBehavior.down
..onStart = _handleDragStart ..onStart = _handleDragStart
@ -704,7 +704,7 @@ class _EditorTextSelectionGestureDetectorState
gestures[ForcePressGestureRecognizer] = gestures[ForcePressGestureRecognizer] =
GestureRecognizerFactoryWithHandlers<ForcePressGestureRecognizer>( GestureRecognizerFactoryWithHandlers<ForcePressGestureRecognizer>(
() => ForcePressGestureRecognizer(debugOwner: this), () => ForcePressGestureRecognizer(debugOwner: this),
(ForcePressGestureRecognizer instance) { (instance) {
instance instance
..onStart = ..onStart =
widget.onForcePressStart != null ? _forcePressStarted : null widget.onForcePressStart != null ? _forcePressStarted : null

@ -1251,7 +1251,7 @@ class _QuillDropdownButtonState<T> extends State<QuillDropdownButton<T>> {
// widget.shape ?? popupMenuTheme.shape, // widget.shape ?? popupMenuTheme.shape,
color: popupMenuTheme.color, // widget.color ?? popupMenuTheme.color, color: popupMenuTheme.color, // widget.color ?? popupMenuTheme.color,
// captureInheritedThemes: widget.captureInheritedThemes, // captureInheritedThemes: widget.captureInheritedThemes,
).then((T? newValue) { ).then((newValue) {
if (!mounted) return null; if (!mounted) return null;
if (newValue == null) { if (newValue == null) {
// if (widget.onCanceled != null) widget.onCanceled(); // if (widget.onCanceled != null) widget.onCanceled();

Loading…
Cancel
Save