Skip to content

Commit

Permalink
refactor: Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
witwash committed Sep 11, 2024
1 parent 132b48e commit 0689de6
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 20 deletions.
13 changes: 9 additions & 4 deletions optimus/lib/src/common/anchored_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ abstract class AnchoredOverlayController {
const AnchoredOverlayController();

double get maxHeight;

double get width;

double get top;

double get bottom;
}

Expand Down Expand Up @@ -128,10 +131,12 @@ class AnchoredOverlayState extends State<AnchoredOverlay>
size;
}

RenderBox? _getOverlay() =>
Overlay.of(context, rootOverlay: widget.useRootOverlay)
.context
.findRenderObject() as RenderBox?;
RenderBox? _getOverlay() {
final renderBox = Overlay.of(context, rootOverlay: widget.useRootOverlay)
.context
.findRenderObject();
if (renderBox is RenderBox) return renderBox;
}

Size? _getOverlaySize() => _getOverlay()?.size;

Expand Down
4 changes: 2 additions & 2 deletions optimus/lib/src/dropdown/dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ class _GroupedDropdownListViewState<T>

int? result = widget.groupBy(value1).compareTo(widget.groupBy(value2));
if (result == 0) {
if (value1 is Comparable) {
result = value1.compareTo(value2 as Comparable);
if (value1 is Comparable && value2 is Comparable) {
result = value1.compareTo(value2);
}
} else {
groupsCount++;
Expand Down
3 changes: 0 additions & 3 deletions optimus/lib/src/dropdown/dropdown_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ abstract class OptimusDropdownTile<T> extends StatelessWidget {
const OptimusDropdownTile({super.key, required this.value});

final T value;

@override
Widget build(BuildContext context);
}

class ListDropdownTile<T> extends OptimusDropdownTile<T> {
Expand Down
4 changes: 2 additions & 2 deletions optimus/lib/src/expansion/expansion_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class _OptimusExpansionTileState extends State<OptimusExpansionTile>
_heightFactor = _controller.drive(_easeInTween);
_iconTurns = _controller.drive(_halfTween.chain(_easeInTween));

_isExpanded = (PageStorage.of(context).readState(context) ??
widget.isInitiallyExpanded) as bool;
final stateValue = PageStorage.of(context).readState(context);
_isExpanded = stateValue is bool ? stateValue : widget.isInitiallyExpanded;
if (_isExpanded) _controller.value = 1.0;
}

Expand Down
1 change: 1 addition & 0 deletions optimus/lib/src/feedback/alert_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class _NoClipSizeTransition extends AnimatedWidget {

final Widget? child;

// ignore: avoid-type-casts, no need to check, can't be anything else
Animation<double> get sizeFactor => listenable as Animation<double>;

@override
Expand Down
12 changes: 9 additions & 3 deletions optimus/lib/src/form/date_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ class DateFormatter extends TextInputFormatter {
newText[oldSelectionStart],
);
resultSelection = _getNextInputIndex(newSelectionStart);

return TextEditingValue(
text: resultText,
selection: TextSelection.collapsed(offset: resultSelection),
);
}
} else if (newText.length < oldText.length) {
if (_isValidDigit(oldText[newSelectionStart])) {
Expand All @@ -180,9 +185,10 @@ class DateFormatter extends TextInputFormatter {
placeholder.substring(start, end),
);

if (_inputLength(resultText) == 0) resultText = '';

resultSelection = selectionPosition;
return TextEditingValue(
text: _inputLength(resultText) == 0 ? '' : resultText,
selection: TextSelection.collapsed(offset: selectionPosition),
);
} else if (_isDesignatedSpace(newSelectionStart)) {
final prevInputSpace = _getPreviousInputIndex(newSelectionStart);
if (_isValidDigit(oldText[prevInputSpace])) {
Expand Down
1 change: 1 addition & 0 deletions optimus/lib/src/form/date_input_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ class OptimusDateInputFormField extends FormField<DateTime?> {
class _DateInputFormFieldState extends FormFieldState<DateTime?> {
@override
OptimusDateInputFormField get widget =>
// ignore: avoid-type-casts, no need to check, can't be anything else
super.widget as OptimusDateInputFormField;
}
2 changes: 2 additions & 0 deletions optimus/lib/src/form/input_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class OptimusInputFormField extends FormField<String> {
controller != null ? controller.text : (initialValue ?? ''),
enabled: isEnabled,
builder: (FormFieldState<String> field) {
// ignore: avoid-type-casts, can't be anything else. No need to check
final _InputFormFieldState state = field as _InputFormFieldState;

return OptimusInputField(
Expand Down Expand Up @@ -114,6 +115,7 @@ class _InputFormFieldState extends FormFieldState<String> {
// initialized at this point

@override
// ignore: avoid-type-casts, can't be anything else. No need to check.
OptimusInputFormField get widget => super.widget as OptimusInputFormField;

@override
Expand Down
2 changes: 2 additions & 0 deletions optimus/lib/src/tokens/tokens_dark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// tokens_dark.dart
//

// ignore_for_file: avoid-duplicate-constant-values

// Do not edit directly
// Generated on Mon, 02 Sep 2024 13:49:23 GMT

Expand Down
2 changes: 2 additions & 0 deletions optimus/lib/src/tokens/tokens_light.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// tokens_light.dart
//

// ignore_for_file: avoid-duplicate-constant-values

// Do not edit directly
// Generated on Mon, 02 Sep 2024 13:49:22 GMT

Expand Down
14 changes: 8 additions & 6 deletions optimus/lib/src/tooltip/tooltip_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TooltipOverlayState extends State<TooltipOverlay>
late Rect _savedRect = _calculateRect(widget.anchorKey);
late Rect _tooltipRect = _calculateRect(widget.tooltipKey);
late Size? _overlaySize = _getOverlaySize();
late OptimusTooltipPosition _position = _getPreferredPosition;
late OptimusTooltipPosition _position = _preferredPosition;

double _opacity = 0.0;

Expand Down Expand Up @@ -112,7 +112,7 @@ class TooltipOverlayState extends State<TooltipOverlay>
double get _verticalCenterBottom =>
_savedRect.top - _savedRect.height / 2 + _tooltipRect.height / 2;

OptimusTooltipPosition get _getPreferredPosition =>
OptimusTooltipPosition get _preferredPosition =>
widget.position ?? _fallbackPosition;

OptimusTooltipPosition get _fallbackPosition =>
Expand Down Expand Up @@ -280,10 +280,12 @@ class TooltipOverlayState extends State<TooltipOverlay>
size;
}

RenderBox? _getOverlay() =>
Overlay.of(context, rootOverlay: widget.useRootOverlay)
.context
.findRenderObject() as RenderBox?;
RenderBox? _getOverlay() {
final renderObject = Overlay.of(context, rootOverlay: widget.useRootOverlay)
.context
.findRenderObject();
if (renderObject is RenderBox) return renderObject;
}

Size? _getOverlaySize() => _getOverlay()?.size;

Expand Down
2 changes: 2 additions & 0 deletions optimus_icons/utils/gen_icons.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/// Copyright (c) 2020, Mike Hoolehan, StarHeight Media
/// All rights reserved.
// ignore_for_file: avoid-type-casts, utility script

/// Redistribution and use in source and binary forms, with or without
/// modification, are permitted provided that the following conditions are met:
/// * Redistributions of source code must retain the above copyright
Expand Down

0 comments on commit 0689de6

Please sign in to comment.