Skip to content

Commit 946d1e7

Browse files
committed
Fix dynamic label updates in AdaptivePopupMenuItem
1 parent af94190 commit 946d1e7

File tree

3 files changed

+23
-49
lines changed

3 files changed

+23
-49
lines changed

lib/src/widgets/adaptive_alert_dialog.dart

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ class AdaptiveAlertDialog {
9494
// Build custom content if icon or OTP is present
9595
if (icon != null || oneTimeCode != null || message != null) {
9696
contentWidget = ConstrainedBox(
97-
constraints: const BoxConstraints(
98-
minHeight: 60,
99-
maxHeight: 300,
100-
),
97+
constraints: const BoxConstraints(minHeight: 60, maxHeight: 300),
10198
child: SingleChildScrollView(
10299
child: Column(
103100
mainAxisSize: MainAxisSize.min,
@@ -238,18 +235,13 @@ class AdaptiveAlertDialog {
238235

239236
// Build custom content with text field
240237
contentWidget = ConstrainedBox(
241-
constraints: const BoxConstraints(
242-
minHeight: 100,
243-
maxHeight: 300,
244-
),
238+
constraints: const BoxConstraints(minHeight: 100, maxHeight: 300),
245239
child: SingleChildScrollView(
246240
child: Column(
247241
mainAxisSize: MainAxisSize.min,
248242
crossAxisAlignment: CrossAxisAlignment.stretch,
249243
children: [
250-
if (icon != null &&
251-
icon is IconData &&
252-
iconSize != null) ...[
244+
if (icon != null && icon is IconData && iconSize != null) ...[
253245
Icon(
254246
icon,
255247
size: iconSize,
@@ -294,9 +286,9 @@ class AdaptiveAlertDialog {
294286
} else {
295287
// Other buttons return the entered text
296288
final text = textController.text.trim();
297-
Navigator.of(context).pop<String?>(
298-
text.isNotEmpty ? text : null,
299-
);
289+
Navigator.of(
290+
context,
291+
).pop<String?>(text.isNotEmpty ? text : null);
300292
}
301293
action.onPressed();
302294
},
@@ -443,9 +435,9 @@ class AdaptiveAlertDialog {
443435
if (input != null) {
444436
// Input dialog - return the text
445437
final text = textController.text.trim();
446-
Navigator.of(context).pop<String?>(
447-
text.isNotEmpty ? text : null,
448-
);
438+
Navigator.of(
439+
context,
440+
).pop<String?>(text.isNotEmpty ? text : null);
449441
} else {
450442
// Normal dialog - just close
451443
Navigator.of(context).pop();
@@ -477,4 +469,4 @@ class AdaptiveAlertDialog {
477469
},
478470
);
479471
}
480-
}
472+
}

lib/src/widgets/adaptive_date_picker.dart

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,10 @@ class _CupertinoDatePickerContentState
130130
children: [
131131
// Header with Done button
132132
Container(
133-
padding: const EdgeInsets.symmetric(
134-
horizontal: 16,
135-
vertical: 8,
136-
),
133+
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
137134
decoration: BoxDecoration(
138135
border: Border(
139-
bottom: BorderSide(
140-
color: separatorColor,
141-
width: 0.5,
142-
),
136+
bottom: BorderSide(color: separatorColor, width: 0.5),
143137
),
144138
),
145139
child: Row(
@@ -150,12 +144,8 @@ class _CupertinoDatePickerContentState
150144
onPressed: () => Navigator.of(context).pop(),
151145
child: Text(
152146
PlatformInfo.isIOS
153-
? CupertinoLocalizations.of(
154-
context,
155-
).cancelButtonLabel
156-
: MaterialLocalizations.of(
157-
context,
158-
).cancelButtonLabel,
147+
? CupertinoLocalizations.of(context).cancelButtonLabel
148+
: MaterialLocalizations.of(context).cancelButtonLabel,
159149
),
160150
),
161151
CupertinoButton(

lib/src/widgets/adaptive_time_picker.dart

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ class AdaptiveTimePicker {
5656
);
5757

5858
if (result != null) {
59-
return TimeOfDay(hour: selectedDateTime.hour, minute: selectedDateTime.minute);
59+
return TimeOfDay(
60+
hour: selectedDateTime.hour,
61+
minute: selectedDateTime.minute,
62+
);
6063
}
6164
return null;
6265
}
@@ -112,16 +115,10 @@ class _CupertinoTimePickerContentState
112115
children: [
113116
// Header with Done button
114117
Container(
115-
padding: const EdgeInsets.symmetric(
116-
horizontal: 16,
117-
vertical: 8,
118-
),
118+
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
119119
decoration: BoxDecoration(
120120
border: Border(
121-
bottom: BorderSide(
122-
color: separatorColor,
123-
width: 0.5,
124-
),
121+
bottom: BorderSide(color: separatorColor, width: 0.5),
125122
),
126123
),
127124
child: Row(
@@ -132,18 +129,13 @@ class _CupertinoTimePickerContentState
132129
onPressed: () => Navigator.of(context).pop(),
133130
child: Text(
134131
PlatformInfo.isIOS
135-
? CupertinoLocalizations.of(
136-
context,
137-
).cancelButtonLabel
138-
: MaterialLocalizations.of(
139-
context,
140-
).cancelButtonLabel,
132+
? CupertinoLocalizations.of(context).cancelButtonLabel
133+
: MaterialLocalizations.of(context).cancelButtonLabel,
141134
),
142135
),
143136
CupertinoButton(
144137
padding: EdgeInsets.zero,
145-
onPressed: () =>
146-
Navigator.of(context).pop(selectedDateTime),
138+
onPressed: () => Navigator.of(context).pop(selectedDateTime),
147139
child: Text(
148140
MaterialLocalizations.of(context).okButtonLabel,
149141
style: const TextStyle(fontWeight: FontWeight.w600),

0 commit comments

Comments
 (0)