Skip to content

Commit

Permalink
Remove usage of late from ScreenSize util (#8616)
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough authored Dec 10, 2024
1 parent 25ab25d commit 564de3c
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions packages/devtools_app/lib/src/shared/ui/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,29 +271,30 @@ enum MediaSize with EnumIndexOrdering {
final double heightThreshold;
}

class ScreenSize {
ScreenSize(BuildContext context) {
_height = _calculateHeight(context);
_width = _calculateWidth(context);
final class ScreenSize {
factory ScreenSize(BuildContext context) {
final size = MediaQuery.sizeOf(context);
return ScreenSize._(
height: _calculateHeight(size.height),
width: _calculateWidth(size.width),
);
}

MediaSize get height => _height;
MediaSize get width => _width;
late MediaSize _height;
late MediaSize _width;
ScreenSize._({required this.height, required this.width});

final MediaSize height;
final MediaSize width;

MediaSize _calculateWidth(BuildContext context) {
final width = MediaQuery.of(context).size.width;
static MediaSize _calculateHeight(double height) {
return MediaSize.values.firstWhere(
(size) => width < size.widthThreshold,
(size) => height < size.heightThreshold,
orElse: () => MediaSize.xl,
);
}

MediaSize _calculateHeight(BuildContext context) {
final height = MediaQuery.of(context).size.height;
static MediaSize _calculateWidth(double width) {
return MediaSize.values.firstWhere(
(size) => height < size.heightThreshold,
(size) => width < size.widthThreshold,
orElse: () => MediaSize.xl,
);
}
Expand Down

0 comments on commit 564de3c

Please sign in to comment.