Skip to content

Commit

Permalink
chore: address Dart 3.6.0 analysis warnings (#2417)
Browse files Browse the repository at this point in the history
* chore(flutter_quill_extensions): address warnings of unreachable_switch_default instead of ignoring them

* chore: address warnings of unreachable_switch_default instead of ignoring them
  • Loading branch information
EchoEllet authored Dec 13, 2024
1 parent 2a83b6b commit 5468113
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 37 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Changed

- Address warnings of `unreachable_switch_default` (introduced in Dart 3.6).

## [11.0.0-dev.15] - 2024-12-13

### Added
Expand Down
4 changes: 0 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
include: package:flutter_lints/flutter.yaml

analyzer:
# TODO: Included for backward compatibility, remove when the minimum Dart SDK is 3.6.0
errors:
unreachable_switch_default: ignore
linter:
rules:
always_declare_return_types: true
Expand Down
5 changes: 5 additions & 0 deletions flutter_quill_extensions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Changed

- Address warnings of `unreachable_switch_default` (introduced in Dart 3.6).
- Use `Slider.adaptive` for the image resize slider on Apple platforms for consistency with `CupertinoActionSheet`.

## [11.0.0-dev.6] - 2024-12-13

### Changed
Expand Down
4 changes: 0 additions & 4 deletions flutter_quill_extensions/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
include: package:flutter_lints/flutter.yaml

analyzer:
# TODO: Included for backward compatibility, remove when the minimum Dart SDK is 3.6.0
errors:
unreachable_switch_default: ignore
linter:
rules:
always_declare_return_types: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'package:flutter/cupertino.dart'
show CupertinoActionSheet, CupertinoActionSheetAction;
import 'package:flutter/foundation.dart' show defaultTargetPlatform;
import 'package:flutter/material.dart' show Slider, Card;
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show SchedulerBinding;
import 'package:flutter/widgets.dart';
import 'package:flutter_quill/internal.dart';

class ImageResizer extends StatefulWidget {
Expand Down Expand Up @@ -39,21 +37,10 @@ class ImageResizerState extends State<ImageResizer> {

@override
Widget build(BuildContext context) {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return _showCupertinoMenu();
case TargetPlatform.android:
return _showMaterialMenu();
case TargetPlatform.macOS:
case TargetPlatform.windows:
case TargetPlatform.linux:
case TargetPlatform.fuchsia:
return _showMaterialMenu();
default:
throw UnsupportedError(
'Not supposed to be invoked for $defaultTargetPlatform',
);
if (Theme.of(context).isCupertino) {
return _showCupertinoMenu();
}
return _showMaterialMenu();
}

Widget _showMaterialMenu() {
Expand Down Expand Up @@ -88,7 +75,7 @@ class ImageResizerState extends State<ImageResizer> {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Card(
child: Slider(
child: Slider.adaptive(
value: isWidth ? _width : _height,
max: isWidth ? widget.maxWidth : widget.maxHeight,
divisions: 1000,
Expand Down
5 changes: 0 additions & 5 deletions lib/src/editor/raw_editor/raw_editor_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,6 @@ class QuillRawEditorState extends EditorState
case TargetPlatform.windows:
widget.config.focusNode.unfocus();
break;
default:
throw UnsupportedError(
'The platform ${defaultTargetPlatform.name} is not supported in the'
' _defaultOnTapOutside()',
);
}
}

Expand Down
6 changes: 0 additions & 6 deletions lib/src/editor/widgets/text/text_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ class EditorTextSelectionOverlay {
? newSelection.extent
: const TextPosition(offset: 0);
break;
default:
throw ArgumentError('Invalid position');
}

final currSelection = newSelection != null
Expand Down Expand Up @@ -456,8 +454,6 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
return renderObject.selectionStartInViewport;
case _TextSelectionHandlePosition.end:
return renderObject.selectionEndInViewport;
default:
throw ArgumentError('Invalid position');
}
}
}
Expand Down Expand Up @@ -547,8 +543,6 @@ class _TextSelectionHandleOverlayState
isNormalized ? position.offset : widget.selection.extentOffset,
);
break;
default:
throw ArgumentError('Invalid widget.position');
}

if (newSelection.baseOffset >= newSelection.extentOffset) {
Expand Down

0 comments on commit 5468113

Please sign in to comment.