diff --git a/optimus/lib/src/common/anchored_overlay.dart b/optimus/lib/src/common/anchored_overlay.dart index ab2eba61..4c2a0d69 100644 --- a/optimus/lib/src/common/anchored_overlay.dart +++ b/optimus/lib/src/common/anchored_overlay.dart @@ -7,8 +7,11 @@ abstract class AnchoredOverlayController { const AnchoredOverlayController(); double get maxHeight; + double get width; + double get top; + double get bottom; } @@ -128,10 +131,12 @@ class AnchoredOverlayState extends State 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; diff --git a/optimus/lib/src/dropdown/dropdown.dart b/optimus/lib/src/dropdown/dropdown.dart index e85287a6..09434032 100644 --- a/optimus/lib/src/dropdown/dropdown.dart +++ b/optimus/lib/src/dropdown/dropdown.dart @@ -287,8 +287,8 @@ class _GroupedDropdownListViewState 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++; diff --git a/optimus/lib/src/dropdown/dropdown_tile.dart b/optimus/lib/src/dropdown/dropdown_tile.dart index 1d13d46e..cddb0029 100644 --- a/optimus/lib/src/dropdown/dropdown_tile.dart +++ b/optimus/lib/src/dropdown/dropdown_tile.dart @@ -5,9 +5,6 @@ abstract class OptimusDropdownTile extends StatelessWidget { const OptimusDropdownTile({super.key, required this.value}); final T value; - - @override - Widget build(BuildContext context); } class ListDropdownTile extends OptimusDropdownTile { diff --git a/optimus/lib/src/expansion/expansion_tile.dart b/optimus/lib/src/expansion/expansion_tile.dart index d7adcdc5..fffc1094 100644 --- a/optimus/lib/src/expansion/expansion_tile.dart +++ b/optimus/lib/src/expansion/expansion_tile.dart @@ -103,8 +103,8 @@ class _OptimusExpansionTileState extends State _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; } diff --git a/optimus/lib/src/feedback/alert_overlay.dart b/optimus/lib/src/feedback/alert_overlay.dart index 284b47fa..d9836b45 100644 --- a/optimus/lib/src/feedback/alert_overlay.dart +++ b/optimus/lib/src/feedback/alert_overlay.dart @@ -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 get sizeFactor => listenable as Animation; @override diff --git a/optimus/lib/src/form/date_formatter.dart b/optimus/lib/src/form/date_formatter.dart index ae3d5ff2..0fbbe5fb 100644 --- a/optimus/lib/src/form/date_formatter.dart +++ b/optimus/lib/src/form/date_formatter.dart @@ -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])) { @@ -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])) { diff --git a/optimus/lib/src/form/date_input_form_field.dart b/optimus/lib/src/form/date_input_form_field.dart index 099ddcc1..987d1b8c 100644 --- a/optimus/lib/src/form/date_input_form_field.dart +++ b/optimus/lib/src/form/date_input_form_field.dart @@ -45,5 +45,6 @@ class OptimusDateInputFormField extends FormField { class _DateInputFormFieldState extends FormFieldState { @override OptimusDateInputFormField get widget => + // ignore: avoid-type-casts, no need to check, can't be anything else super.widget as OptimusDateInputFormField; } diff --git a/optimus/lib/src/form/input_form_field.dart b/optimus/lib/src/form/input_form_field.dart index fad54e9f..a009164e 100644 --- a/optimus/lib/src/form/input_form_field.dart +++ b/optimus/lib/src/form/input_form_field.dart @@ -54,6 +54,7 @@ class OptimusInputFormField extends FormField { controller != null ? controller.text : (initialValue ?? ''), enabled: isEnabled, builder: (FormFieldState field) { + // ignore: avoid-type-casts, can't be anything else. No need to check final _InputFormFieldState state = field as _InputFormFieldState; return OptimusInputField( @@ -114,6 +115,7 @@ class _InputFormFieldState extends FormFieldState { // 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 diff --git a/optimus/lib/src/tokens/tokens_dark.dart b/optimus/lib/src/tokens/tokens_dark.dart index 24363dde..96c7d752 100644 --- a/optimus/lib/src/tokens/tokens_dark.dart +++ b/optimus/lib/src/tokens/tokens_dark.dart @@ -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 diff --git a/optimus/lib/src/tokens/tokens_light.dart b/optimus/lib/src/tokens/tokens_light.dart index e55732bf..7965b277 100644 --- a/optimus/lib/src/tokens/tokens_light.dart +++ b/optimus/lib/src/tokens/tokens_light.dart @@ -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 diff --git a/optimus/lib/src/tooltip/tooltip_overlay.dart b/optimus/lib/src/tooltip/tooltip_overlay.dart index 9356df30..5404daef 100644 --- a/optimus/lib/src/tooltip/tooltip_overlay.dart +++ b/optimus/lib/src/tooltip/tooltip_overlay.dart @@ -62,7 +62,7 @@ class TooltipOverlayState extends State 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; @@ -112,7 +112,7 @@ class TooltipOverlayState extends State double get _verticalCenterBottom => _savedRect.top - _savedRect.height / 2 + _tooltipRect.height / 2; - OptimusTooltipPosition get _getPreferredPosition => + OptimusTooltipPosition get _preferredPosition => widget.position ?? _fallbackPosition; OptimusTooltipPosition get _fallbackPosition => @@ -280,10 +280,12 @@ class TooltipOverlayState extends State 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; diff --git a/optimus_icons/utils/gen_icons.dart b/optimus_icons/utils/gen_icons.dart index c985af1b..a2b61683 100644 --- a/optimus_icons/utils/gen_icons.dart +++ b/optimus_icons/utils/gen_icons.dart @@ -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