Skip to content

Commit ce6ab8b

Browse files
committed
fix: update color opacity method and improve image answer view state management
1 parent c9fc731 commit ce6ab8b

File tree

6 files changed

+84
-78
lines changed

6 files changed

+84
-78
lines changed

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class _MyAppState extends State<MyApp> {
4747
themeData: Theme.of(context).copyWith(
4848
primaryColor: Colors.cyan,
4949
appBarTheme: const AppBarTheme(
50-
color: Colors.white,
50+
backgroundColor: Colors.white,
5151
iconTheme: IconThemeData(
5252
color: Colors.cyan,
5353
),

example/pubspec.lock

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,26 @@ packages:
8585
dependency: transitive
8686
description:
8787
name: characters
88-
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
88+
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
8989
url: "https://pub.dev"
9090
source: hosted
91-
version: "1.4.0"
91+
version: "1.3.0"
9292
clock:
9393
dependency: transitive
9494
description:
9595
name: clock
96-
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
96+
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
9797
url: "https://pub.dev"
9898
source: hosted
99-
version: "1.1.2"
99+
version: "1.1.1"
100100
collection:
101101
dependency: transitive
102102
description:
103103
name: collection
104-
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
104+
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
105105
url: "https://pub.dev"
106106
source: hosted
107-
version: "1.19.1"
107+
version: "1.19.0"
108108
cross_file:
109109
dependency: transitive
110110
description:
@@ -149,10 +149,10 @@ packages:
149149
dependency: transitive
150150
description:
151151
name: fake_async
152-
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
152+
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
153153
url: "https://pub.dev"
154154
source: hosted
155-
version: "1.3.3"
155+
version: "1.3.1"
156156
ffi:
157157
dependency: transitive
158158
description:
@@ -379,26 +379,26 @@ packages:
379379
dependency: transitive
380380
description:
381381
name: leak_tracker
382-
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
382+
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
383383
url: "https://pub.dev"
384384
source: hosted
385-
version: "11.0.2"
385+
version: "10.0.7"
386386
leak_tracker_flutter_testing:
387387
dependency: transitive
388388
description:
389389
name: leak_tracker_flutter_testing
390-
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
390+
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
391391
url: "https://pub.dev"
392392
source: hosted
393-
version: "3.0.10"
393+
version: "3.0.8"
394394
leak_tracker_testing:
395395
dependency: transitive
396396
description:
397397
name: leak_tracker_testing
398-
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
398+
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
399399
url: "https://pub.dev"
400400
source: hosted
401-
version: "3.0.2"
401+
version: "3.0.1"
402402
lottie:
403403
dependency: transitive
404404
description:
@@ -419,10 +419,10 @@ packages:
419419
dependency: transitive
420420
description:
421421
name: matcher
422-
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
422+
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
423423
url: "https://pub.dev"
424424
source: hosted
425-
version: "0.12.17"
425+
version: "0.12.16+1"
426426
material_color_utilities:
427427
dependency: transitive
428428
description:
@@ -435,10 +435,10 @@ packages:
435435
dependency: transitive
436436
description:
437437
name: meta
438-
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
438+
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
439439
url: "https://pub.dev"
440440
source: hosted
441-
version: "1.16.0"
441+
version: "1.15.0"
442442
mime:
443443
dependency: transitive
444444
description:
@@ -459,10 +459,10 @@ packages:
459459
dependency: transitive
460460
description:
461461
name: path
462-
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
462+
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
463463
url: "https://pub.dev"
464464
source: hosted
465-
version: "1.9.1"
465+
version: "1.9.0"
466466
platform:
467467
dependency: transitive
468468
description:
@@ -528,18 +528,18 @@ packages:
528528
dependency: transitive
529529
description:
530530
name: stack_trace
531-
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
531+
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
532532
url: "https://pub.dev"
533533
source: hosted
534-
version: "1.12.1"
534+
version: "1.12.0"
535535
stream_channel:
536536
dependency: transitive
537537
description:
538538
name: stream_channel
539-
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
539+
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
540540
url: "https://pub.dev"
541541
source: hosted
542-
version: "2.1.4"
542+
version: "2.1.2"
543543
stream_transform:
544544
dependency: transitive
545545
description:
@@ -591,10 +591,10 @@ packages:
591591
dependency: transitive
592592
description:
593593
name: test_api
594-
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
594+
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
595595
url: "https://pub.dev"
596596
source: hosted
597-
version: "0.7.6"
597+
version: "0.7.3"
598598
typed_data:
599599
dependency: transitive
600600
description:
@@ -679,10 +679,10 @@ packages:
679679
dependency: transitive
680680
description:
681681
name: vector_math
682-
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
682+
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
683683
url: "https://pub.dev"
684684
source: hosted
685-
version: "2.2.0"
685+
version: "2.1.4"
686686
video_player:
687687
dependency: transitive
688688
description:
@@ -748,5 +748,5 @@ packages:
748748
source: hosted
749749
version: "3.0.4"
750750
sdks:
751-
dart: ">=3.8.0-0 <4.0.0"
751+
dart: ">=3.6.0 <4.0.0"
752752
flutter: ">=3.27.0"

lib/src/views/agreement_answer_view.dart

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -86,42 +86,43 @@ class _AgreementAnswerViewState extends State<AgreementAnswerView> {
8686
href != null ? launchUrl(Uri.parse(href)) : null,
8787
),
8888
),
89-
Row(
90-
crossAxisAlignment: CrossAxisAlignment.center,
91-
children: [
92-
Radio<BooleanResult>(
93-
groupValue: _result,
94-
value: BooleanResult.POSITIVE,
95-
onChanged: (v) {
89+
RadioGroup<BooleanResult>(
90+
groupValue: _result,
91+
onChanged: (v) {
92+
setState(() {
93+
_result = v;
94+
});
95+
},
96+
child: Row(
97+
crossAxisAlignment: CrossAxisAlignment.center,
98+
children: [
99+
Radio<BooleanResult>(value: BooleanResult.POSITIVE),
100+
SizedBox(
101+
width: 16,
102+
),
103+
Expanded(
104+
child: GestureDetector(
105+
onTap: () {
96106
setState(() {
97-
_result = v;
107+
if (_result == BooleanResult.POSITIVE) {
108+
_result = BooleanResult.NEGATIVE;
109+
} else {
110+
_result = BooleanResult.POSITIVE;
111+
}
98112
});
99-
}),
100-
SizedBox(
101-
width: 16,
102-
),
103-
Expanded(
104-
child: GestureDetector(
105-
onTap: () {
106-
setState(() {
107-
if (_result == BooleanResult.POSITIVE) {
108-
_result = BooleanResult.NEGATIVE;
109-
} else {
110-
_result = BooleanResult.POSITIVE;
111-
}
112-
});
113-
},
114-
child: MarkdownBody(
115-
styleSheet: markDownStyleSheet.copyWith(
116-
p: theme.textTheme.bodySmall,
113+
},
114+
child: MarkdownBody(
115+
styleSheet: markDownStyleSheet.copyWith(
116+
p: theme.textTheme.bodySmall,
117+
),
118+
data: _agreementAnswerFormat.markdownAgreementText ??
119+
'',
120+
onTapLink: (text, href, title) =>
121+
href != null ? launchUrl(Uri.parse(href)) : null,
117122
),
118-
data:
119-
_agreementAnswerFormat.markdownAgreementText ?? '',
120-
onTapLink: (text, href, title) =>
121-
href != null ? launchUrl(Uri.parse(href)) : null,
122-
),
123-
)),
124-
],
123+
)),
124+
],
125+
),
125126
)
126127
],
127128
),

lib/src/views/decoration/input_decoration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ InputDecoration textFieldInputDecoration({String hint = ''}) => InputDecoration(
1212
Radius.zero,
1313
),
1414
borderSide: BorderSide(
15-
color: Colors.black.withOpacity(0.2),
15+
color: Colors.black.withValues(alpha: 0.2),
1616
),
1717
),
1818
enabledBorder: OutlineInputBorder(
1919
borderRadius: BorderRadius.all(
2020
Radius.zero,
2121
),
2222
borderSide: BorderSide(
23-
color: Colors.black.withOpacity(0.2),
23+
color: Colors.black.withValues(alpha: 0.2),
2424
),
2525
),
2626
hintText: hint,

lib/src/views/widget/time_picker_widget.dart

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ class _HourMinuteControl extends StatelessWidget {
270270
final Color backgroundColor = timePickerTheme.hourMinuteColor ??
271271
WidgetStateColor.resolveWith((Set<WidgetState> states) {
272272
return states.contains(WidgetState.selected)
273-
? themeData.colorScheme.primary.withOpacity(isDark ? 0.24 : 0.12)
274-
: themeData.colorScheme.onSurface.withOpacity(0.12);
273+
? themeData.colorScheme.primary
274+
.withValues(alpha: isDark ? 0.24 : 0.12)
275+
: themeData.colorScheme.onSurface.withValues(alpha: 0.12);
275276
});
276277
final TextStyle style = timePickerTheme.hourMinuteTextStyle ??
277278
themeData.textTheme.displayMedium!;
@@ -542,7 +543,7 @@ class _DayPeriodControl extends StatelessWidget {
542543
WidgetStateColor.resolveWith((Set<WidgetState> states) {
543544
return states.contains(WidgetState.selected)
544545
? colorScheme.primary
545-
: colorScheme.onSurface.withOpacity(0.60);
546+
: colorScheme.onSurface.withValues(alpha: 0.60);
546547
});
547548
final Color backgroundColor = timePickerTheme.dayPeriodColor ??
548549
WidgetStateColor.resolveWith((Set<WidgetState> states) {
@@ -551,7 +552,7 @@ class _DayPeriodControl extends StatelessWidget {
551552
// and allows the optional elevation overlay for dark mode to be
552553
// visible.
553554
return states.contains(WidgetState.selected)
554-
? colorScheme.primary.withOpacity(isDark ? 0.24 : 0.12)
555+
? colorScheme.primary.withValues(alpha: isDark ? 0.24 : 0.12)
555556
: Colors.transparent;
556557
});
557558
final bool amSelected = selectedTime.period == DayPeriod.am;
@@ -572,8 +573,8 @@ class _DayPeriodControl extends StatelessWidget {
572573
const RoundedRectangleBorder(borderRadius: _kDefaultBorderRadius);
573574
final BorderSide borderSide = timePickerTheme.dayPeriodBorderSide ??
574575
BorderSide(
575-
color: Color.alphaBlend(
576-
colorScheme.onSurface.withOpacity(0.38), colorScheme.surface),
576+
color: Color.alphaBlend(colorScheme.onSurface.withValues(alpha: 0.38),
577+
colorScheme.surface),
577578
);
578579
// Apply the custom borderSide.
579580
shape = shape.copyWith(
@@ -1270,7 +1271,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
12701271
final ThemeData theme = Theme.of(context);
12711272
final TimePickerThemeData pickerTheme = TimePickerTheme.of(context);
12721273
final Color backgroundColor = pickerTheme.dialBackgroundColor ??
1273-
themeData.colorScheme.onSurface.withOpacity(0.12);
1274+
themeData.colorScheme.onSurface.withValues(alpha: 0.12);
12741275
final Color accentColor =
12751276
pickerTheme.dialHandColor ?? themeData.colorScheme.primary;
12761277
final Color primaryLabelColor = WidgetStateProperty.resolveAs(
@@ -1715,8 +1716,7 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> {
17151716
final TimePickerThemeData timePickerTheme = TimePickerTheme.of(context);
17161717
final ColorScheme colorScheme = theme.colorScheme;
17171718

1718-
final InputDecorationThemeData? inputDecorationTheme =
1719-
timePickerTheme.inputDecorationTheme;
1719+
final inputDecorationTheme = timePickerTheme.inputDecorationTheme;
17201720
InputDecoration inputDecoration;
17211721
if (inputDecorationTheme != null) {
17221722
inputDecoration =
@@ -1738,14 +1738,14 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> {
17381738
borderSide: BorderSide(color: colorScheme.error, width: 2.0),
17391739
),
17401740
hintStyle: widget.style
1741-
.copyWith(color: colorScheme.onSurface.withOpacity(0.36)),
1741+
.copyWith(color: colorScheme.onSurface.withValues(alpha: 0.36)),
17421742
errorStyle: const TextStyle(
17431743
fontSize: 0.0,
17441744
height: 0.0), // Prevent the error text from appearing.
17451745
);
17461746
}
17471747
final Color unfocusedFillColor = timePickerTheme.hourMinuteColor ??
1748-
colorScheme.onSurface.withOpacity(0.12);
1748+
colorScheme.onSurface.withValues(alpha: 0.12);
17491749
// If screen reader is in use, make the hint text say hours/minutes.
17501750
// Otherwise, remove the hint text when focused because the centered cursor
17511751
// appears odd above the hint text.
@@ -2031,8 +2031,9 @@ class _TimePickerWidgetState extends State<TimePickerWidget> {
20312031
const SizedBox(width: 10.0),
20322032
IconButton(
20332033
color: TimePickerTheme.of(context).entryModeIconColor ??
2034-
theme.colorScheme.onSurface.withOpacity(
2035-
theme.colorScheme.brightness == Brightness.dark ? 1.0 : 0.6,
2034+
theme.colorScheme.onSurface.withValues(
2035+
alpha:
2036+
theme.colorScheme.brightness == Brightness.dark ? 1.0 : 0.6,
20362037
),
20372038
onPressed: _handleEntryModeToggle,
20382039
icon: Icon(_entryMode == TimePickerEntryMode.dial

packages/survey_kit_image_answer/lib/src/view/image_answer_view.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ class _ImageAnswerViewState extends State<ImageAnswerView> {
158158
source: ImageSource.camera,
159159
);
160160

161+
if (!mounted) return;
162+
161163
Navigator.pop(context);
162164

163165
picture?.readAsBytes().then((value) {
@@ -172,6 +174,8 @@ class _ImageAnswerViewState extends State<ImageAnswerView> {
172174
source: ImageSource.gallery,
173175
);
174176

177+
if (!mounted) return;
178+
175179
Navigator.pop(context);
176180

177181
picture?.readAsBytes().then((value) {

0 commit comments

Comments
 (0)