Skip to content

Commit

Permalink
Merge pull request #10 from nilsreichardt/upgrade-to-flutter-v3-22-0
Browse files Browse the repository at this point in the history
Upgrade to Flutter v3.22.0
  • Loading branch information
Fleximex authored May 21, 2024
2 parents 4064bc9 + 425c773 commit 7cc2303
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
29 changes: 13 additions & 16 deletions lib/interval_time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class _HourMinuteControl extends StatelessWidget {
text,
style: style.copyWith(
color: MaterialStateProperty.resolveAs(textColor, states)),
textScaleFactor: 1.0,
textScaler: MediaQuery.textScalerOf(context),
),
),
),
Expand Down Expand Up @@ -425,7 +425,7 @@ class _StringFragment extends StatelessWidget {
style: hourMinuteStyle.apply(
color: MaterialStateProperty.resolveAs(
textColor, <MaterialState>{})),
textScaleFactor: 1.0,
textScaler: MediaQuery.textScalerOf(context),
),
),
),
Expand Down Expand Up @@ -594,8 +594,7 @@ class _DayPeriodControl extends StatelessWidget {
side: borderSide,
);

final double buttonTextScaleFactor =
math.min(MediaQuery.of(context).textScaleFactor, 2.0);
const maxScaleFactor = 2.0;

final Widget amButton = Material(
color: MaterialStateProperty.resolveAs(backgroundColor, amStates),
Expand All @@ -609,7 +608,8 @@ class _DayPeriodControl extends StatelessWidget {
child: Text(
materialLocalizations.anteMeridiemAbbreviation,
style: amStyle,
textScaleFactor: buttonTextScaleFactor,
textScaler: MediaQuery.textScalerOf(context)
.clamp(maxScaleFactor: maxScaleFactor),
),
),
),
Expand All @@ -628,7 +628,8 @@ class _DayPeriodControl extends StatelessWidget {
child: Text(
materialLocalizations.postMeridiemAbbreviation,
style: pmStyle,
textScaleFactor: buttonTextScaleFactor,
textScaler: MediaQuery.textScalerOf(context)
.clamp(maxScaleFactor: maxScaleFactor),
),
),
),
Expand Down Expand Up @@ -1232,7 +1233,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
painter: TextPainter(
text: TextSpan(style: style, text: label),
textDirection: TextDirection.ltr,
textScaleFactor: labelScaleFactor,
textScaler: MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 2.0),
)..layout(),
onTap: onTap,
);
Expand Down Expand Up @@ -1849,7 +1850,7 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField>
// TODO(rami-a): Once https://github.com/flutter/flutter/issues/67571 is
// resolved, remove the window check for semantics being enabled on web.
final String? hintText = MediaQuery.of(context).accessibleNavigation ||
WidgetsBinding.instance.window.semanticsEnabled
View.of(context).platformDispatcher.semanticsEnabled
? widget.semanticHintText
: (focusNode.hasFocus ? null : _formattedValue);
inputDecoration = inputDecoration.copyWith(
Expand All @@ -1862,7 +1863,8 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField>
return SizedBox(
height: _kTimePickerHeaderControlHeight,
child: MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
data:
MediaQuery.of(context).copyWith(textScaler: TextScaler.linear(1.0)),
child: UnmanagedRestorationScope(
bucket: bucket,
child: TextFormField(
Expand Down Expand Up @@ -2300,11 +2302,6 @@ class _IntervalTimePickerDialogState extends State<IntervalTimePickerDialog>
Size _dialogSize(BuildContext context) {
final Orientation orientation = MediaQuery.of(context).orientation;
final ThemeData theme = Theme.of(context);
// Constrain the textScaleFactor to prevent layout issues. Since only some
// parts of the time picker scale up with textScaleFactor, we cap the factor
// to 1.1 as that provides enough space to reasonably fit all the content.
final double textScaleFactor =
math.min(MediaQuery.of(context).textScaleFactor, 1.1);

final double timePickerWidth;
final double timePickerHeight;
Expand All @@ -2320,7 +2317,7 @@ class _IntervalTimePickerDialogState extends State<IntervalTimePickerDialog>
: _kTimePickerHeightPortraitCollapsed;
break;
case Orientation.landscape:
timePickerWidth = _kTimePickerWidthLandscape * textScaleFactor;
timePickerWidth = _kTimePickerWidthLandscape;
timePickerHeight =
theme.materialTapTargetSize == MaterialTapTargetSize.padded
? _kTimePickerHeightLandscape
Expand All @@ -2334,7 +2331,7 @@ class _IntervalTimePickerDialogState extends State<IntervalTimePickerDialog>
timePickerHeight = _kTimePickerHeightInput;
break;
}
return Size(timePickerWidth, timePickerHeight * textScaleFactor);
return Size(timePickerWidth, timePickerHeight);
}

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage: https://github.com/Fleximex/interval_time_picker
repository: https://github.com/Fleximex/interval_time_picker

environment:
sdk: '>=2.18.0 <3.0.0'
sdk: '>=2.18.0 <4.0.0'

dependencies:
flutter:
Expand Down

0 comments on commit 7cc2303

Please sign in to comment.