Skip to content

Commit 61a59be

Browse files
committed
refactor: Migrate to Flutter 3.16.0
1 parent 093b89f commit 61a59be

File tree

5 files changed

+21
-30
lines changed

5 files changed

+21
-30
lines changed

optimus/lib/src/avatar.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class OptimusAvatar extends StatelessWidget {
4343
),
4444
child: Center(
4545
child: MediaQuery(
46-
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
46+
data: MediaQuery.of(context)
47+
.copyWith(textScaler: TextScaler.noScaling),
4748
child: imageUrl != null
4849
? FadeInImage.memoryNetwork(
4950
width: _diameter,

optimus/lib/src/dropdown/dropdown_select.dart

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,29 +150,24 @@ class _DropdownSelectState<T> extends State<DropdownSelect<T>> {
150150
});
151151
}
152152

153-
bool _handleOnBackPressed() {
153+
void _handleOnBackPressed(bool didPop) {
154+
if (didPop) return;
154155
if (_effectiveFocusNode.hasFocus) {
155156
_effectiveFocusNode.unfocus();
156-
157-
return false;
158-
} else if (widget.embeddedSearch != null) {
159-
final overlay = _overlayEntry;
160-
if (overlay != null) {
161-
_removeOverlay();
162-
163-
return false;
164-
}
165157
}
166-
167-
return true;
158+
final overlay = _overlayEntry;
159+
if (overlay != null) _removeOverlay();
168160
}
169161

162+
bool get _canPop => !_effectiveFocusNode.hasFocus && _overlayEntry == null;
163+
170164
void _showOverlay() {
171165
if (_overlayEntry != null) return;
172166
_overlayEntry = _createOverlayEntry().also((it) {
173167
Overlay.of(context, rootOverlay: widget.rootOverlay).insert(it);
174168
widget.onDropdownShow?.call();
175169
});
170+
setState(() {});
176171
}
177172

178173
void _removeOverlay() {
@@ -291,8 +286,9 @@ class _DropdownSelectState<T> extends State<DropdownSelect<T>> {
291286
isUpdating: widget.isUpdating,
292287
);
293288

294-
return WillPopScope(
295-
onWillPop: () async => _handleOnBackPressed(),
289+
return PopScope(
290+
canPop: _canPop,
291+
onPopInvoked: _handleOnBackPressed,
296292
child: widget.multiselect && _hasValues
297293
? MultiSelectInputField(
298294
values: _values ?? [],

optimus/lib/src/overlay_controller.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,11 @@ class _OverlayControllerState<T> extends State<OverlayController<T>> {
101101
}
102102

103103
@override
104-
Widget build(BuildContext context) => WillPopScope(
105-
onWillPop: () async {
106-
if (widget.focusNode.hasFocus) {
107-
widget.focusNode.unfocus();
108-
109-
return false;
110-
}
111-
112-
return true;
104+
Widget build(BuildContext context) => PopScope(
105+
canPop: !widget.focusNode.hasFocus,
106+
onPopInvoked: (bool didPop) {
107+
if (didPop) return;
108+
widget.focusNode.unfocus();
113109
},
114110
child: widget.child,
115111
);

storybook/lib/stories/icon/icon.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:flutter/foundation.dart';
21
import 'package:flutter/widgets.dart';
32
import 'package:optimus/optimus.dart';
43
import 'package:storybook/utils.dart';
@@ -24,7 +23,7 @@ final Story iconStory = Story(
2423
.map(
2524
(c) => OptimusListTile(
2625
title: OptimusSubsectionTitle(
27-
child: Text(describeEnum(c).toUpperCase()),
26+
child: Text(c.name.toUpperCase()),
2827
),
2928
prefix: OptimusIcon(
3029
iconData: icon,
@@ -53,7 +52,7 @@ final Story supplementaryIconStory = Story(
5352
.map(
5453
(c) => OptimusListTile(
5554
title: OptimusSubsectionTitle(
56-
child: Text(describeEnum(c).toUpperCase()),
55+
child: Text(c.name.toUpperCase()),
5756
),
5857
prefix: OptimusSupplementaryIcon(
5958
iconData: icon,

storybook/lib/stories/tags.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:flutter/foundation.dart';
21
import 'package:flutter/material.dart';
32
import 'package:optimus/optimus.dart';
43
import 'package:storybook/utils.dart';
@@ -32,7 +31,7 @@ final Story tagStory = Story(
3231
(c) => Padding(
3332
padding: const EdgeInsets.all(8),
3433
child: OptimusTag(
35-
text: text.isEmpty ? describeEnum(c) : text,
34+
text: text.isEmpty ? c.name : text,
3635
leadingIcon: leadingIcon,
3736
trailingIcon: trailingIcon,
3837
colorOption: c,
@@ -50,7 +49,7 @@ final Story tagStory = Story(
5049
(c) => Padding(
5150
padding: const EdgeInsets.all(8),
5251
child: OptimusCategoricalTag(
53-
text: text.isEmpty ? describeEnum(c) : text,
52+
text: text.isEmpty ? c.name : text,
5453
leadingIcon: leadingIcon,
5554
trailingIcon: trailingIcon,
5655
colorOption: c,

0 commit comments

Comments
 (0)