Skip to content

Commit

Permalink
refactor!: Migrate to Flutter 3.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
witwash committed Nov 27, 2023
1 parent 093b89f commit 5348fd9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 30 deletions.
3 changes: 2 additions & 1 deletion optimus/lib/src/avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class OptimusAvatar extends StatelessWidget {
),
child: Center(
child: MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
data: MediaQuery.of(context)
.copyWith(textScaler: TextScaler.noScaling),
child: imageUrl != null
? FadeInImage.memoryNetwork(
width: _diameter,
Expand Down
24 changes: 10 additions & 14 deletions optimus/lib/src/dropdown/dropdown_select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,29 +150,24 @@ class _DropdownSelectState<T> extends State<DropdownSelect<T>> {
});
}

bool _handleOnBackPressed() {
void _handleOnBackPressed(bool didPop) {
if (didPop) return;
if (_effectiveFocusNode.hasFocus) {
_effectiveFocusNode.unfocus();

return false;
} else if (widget.embeddedSearch != null) {
final overlay = _overlayEntry;
if (overlay != null) {
_removeOverlay();

return false;
}
}

return true;
final overlay = _overlayEntry;
if (overlay != null) _removeOverlay();
}

bool get _canPop => !_effectiveFocusNode.hasFocus && _overlayEntry == null;

void _showOverlay() {
if (_overlayEntry != null) return;
_overlayEntry = _createOverlayEntry().also((it) {
Overlay.of(context, rootOverlay: widget.rootOverlay).insert(it);
widget.onDropdownShow?.call();
});
setState(() {});
}

void _removeOverlay() {
Expand Down Expand Up @@ -291,8 +286,9 @@ class _DropdownSelectState<T> extends State<DropdownSelect<T>> {
isUpdating: widget.isUpdating,
);

return WillPopScope(
onWillPop: () async => _handleOnBackPressed(),
return PopScope(
canPop: _canPop,
onPopInvoked: _handleOnBackPressed,
child: widget.multiselect && _hasValues
? MultiSelectInputField(
values: _values ?? [],
Expand Down
14 changes: 5 additions & 9 deletions optimus/lib/src/overlay_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,11 @@ class _OverlayControllerState<T> extends State<OverlayController<T>> {
}

@override
Widget build(BuildContext context) => WillPopScope(
onWillPop: () async {
if (widget.focusNode.hasFocus) {
widget.focusNode.unfocus();

return false;
}

return true;
Widget build(BuildContext context) => PopScope(
canPop: !widget.focusNode.hasFocus,
onPopInvoked: (bool didPop) {
if (didPop) return;
widget.focusNode.unfocus();
},
child: widget.child,
);
Expand Down
5 changes: 2 additions & 3 deletions storybook/lib/stories/icon/icon.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:optimus/optimus.dart';
import 'package:storybook/utils.dart';
Expand All @@ -24,7 +23,7 @@ final Story iconStory = Story(
.map(
(c) => OptimusListTile(
title: OptimusSubsectionTitle(
child: Text(describeEnum(c).toUpperCase()),
child: Text(c.name.toUpperCase()),
),
prefix: OptimusIcon(
iconData: icon,
Expand Down Expand Up @@ -53,7 +52,7 @@ final Story supplementaryIconStory = Story(
.map(
(c) => OptimusListTile(
title: OptimusSubsectionTitle(
child: Text(describeEnum(c).toUpperCase()),
child: Text(c.name.toUpperCase()),
),
prefix: OptimusSupplementaryIcon(
iconData: icon,
Expand Down
5 changes: 2 additions & 3 deletions storybook/lib/stories/tags.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:optimus/optimus.dart';
import 'package:storybook/utils.dart';
Expand Down Expand Up @@ -32,7 +31,7 @@ final Story tagStory = Story(
(c) => Padding(
padding: const EdgeInsets.all(8),
child: OptimusTag(
text: text.isEmpty ? describeEnum(c) : text,
text: text.isEmpty ? c.name : text,
leadingIcon: leadingIcon,
trailingIcon: trailingIcon,
colorOption: c,
Expand All @@ -50,7 +49,7 @@ final Story tagStory = Story(
(c) => Padding(
padding: const EdgeInsets.all(8),
child: OptimusCategoricalTag(
text: text.isEmpty ? describeEnum(c) : text,
text: text.isEmpty ? c.name : text,
leadingIcon: leadingIcon,
trailingIcon: trailingIcon,
colorOption: c,
Expand Down

0 comments on commit 5348fd9

Please sign in to comment.