Skip to content

Commit

Permalink
Use improved MediaQuery methods
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Sep 13, 2024
1 parent 8f47459 commit 35603b7
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions packages/flutter_adaptive_scaffold/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.1

* Use improved MediaQuery methods.

## 0.3.0

* Adds `inDuration`, `outDuration`, `inCurve`, and `outCurve` parameters for
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter_adaptive_scaffold/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ class _ItemListTile extends StatelessWidget {
style: Theme.of(context).textTheme.bodyLarge),
const SizedBox(height: 9),
SizedBox(
width: MediaQuery.of(context).size.width,
width: MediaQuery.sizeOf(context).width,
child: (email.bodyImage != '')
? Image.asset(email.bodyImage)
: Container(),
Expand All @@ -717,7 +717,7 @@ class _DetailTile extends StatelessWidget {
return Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: MediaQuery.of(context).size.height,
height: MediaQuery.sizeOf(context).height,
child: Container(
decoration: const BoxDecoration(
color: Color.fromARGB(255, 245, 241, 248),
Expand Down Expand Up @@ -891,7 +891,7 @@ class _EmailTile extends StatelessWidget {
color: Colors.grey[700], height: 1.35, fontSize: 14.5)),
const SizedBox(height: 9),
SizedBox(
width: MediaQuery.of(context).size.width,
width: MediaQuery.sizeOf(context).width,
child:
(bodyImage != '') ? Image.asset(bodyImage) : Container()),
const SizedBox(height: 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class _AdaptiveLayoutState extends State<AdaptiveLayout>
});

Rect? hinge;
for (final DisplayFeature e in MediaQuery.of(context).displayFeatures) {
for (final DisplayFeature e in MediaQuery.displayFeaturesOf(context)) {
if (e.type == DisplayFeatureType.hinge ||
e.type == DisplayFeatureType.fold) {
if (e.bounds.left != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class AdaptiveScaffold extends StatefulWidget {
padding: padding,
child: SizedBox(
width: width,
height: MediaQuery.of(context).size.height,
height: MediaQuery.sizeOf(context).height,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return SingleChildScrollView(
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_adaptive_scaffold/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_adaptive_scaffold
description: Widgets to easily build adaptive layouts, including navigation elements.
version: 0.3.0
version: 0.3.1
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_adaptive_scaffold%22
repository: https://github.com/flutter/packages/tree/main/packages/flutter_adaptive_scaffold

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,35 +443,35 @@ void main() {
class TestBreakpoint0 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width >= 0;
return MediaQuery.sizeOf(context).width >= 0;
}
}

class TestBreakpoint400 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width > 400;
return MediaQuery.sizeOf(context).width > 400;
}
}

class TestBreakpoint800 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width > 800;
return MediaQuery.sizeOf(context).width > 800;
}
}

class TestBreakpoint1200 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width > 1200;
return MediaQuery.sizeOf(context).width > 1200;
}
}

class TestBreakpoint1600 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width > 1600;
return MediaQuery.sizeOf(context).width > 1600;
}
}

Expand Down
20 changes: 10 additions & 10 deletions packages/flutter_adaptive_scaffold/test/test_breakpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,46 @@ import 'package:flutter_adaptive_scaffold/src/breakpoints.dart';
class TestBreakpoint0 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width >= 0 &&
MediaQuery.of(context).size.width < 800;
return MediaQuery.sizeOf(context).width >= 0 &&
MediaQuery.sizeOf(context).width < 800;
}
}

class TestBreakpoint400 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width > 400;
return MediaQuery.sizeOf(context).width > 400;
}
}

class TestBreakpoint800 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width >= 800 &&
MediaQuery.of(context).size.width < 1000;
return MediaQuery.sizeOf(context).width >= 800 &&
MediaQuery.sizeOf(context).width < 1000;
}
}

class TestBreakpoint1000 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width >= 1000 &&
MediaQuery.of(context).size.width < 1200;
return MediaQuery.sizeOf(context).width >= 1000 &&
MediaQuery.sizeOf(context).width < 1200;
}
}

class TestBreakpoint1200 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width >= 1200 &&
MediaQuery.of(context).size.width < 1600;
return MediaQuery.sizeOf(context).width >= 1200 &&
MediaQuery.sizeOf(context).width < 1600;
}
}

class TestBreakpoint1600 extends Breakpoint {
@override
bool isActive(BuildContext context) {
return MediaQuery.of(context).size.width >= 1600;
return MediaQuery.sizeOf(context).width >= 1600;
}
}

Expand Down

0 comments on commit 35603b7

Please sign in to comment.