diff --git a/packages/flutter_adaptive_scaffold/CHANGELOG.md b/packages/flutter_adaptive_scaffold/CHANGELOG.md index 82ac47c78b07..69ffdcd0a516 100644 --- a/packages/flutter_adaptive_scaffold/CHANGELOG.md +++ b/packages/flutter_adaptive_scaffold/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.1 + +* Use improved MediaQuery methods. + ## 0.3.0 * Adds `inDuration`, `outDuration`, `inCurve`, and `outCurve` parameters for diff --git a/packages/flutter_adaptive_scaffold/example/lib/main.dart b/packages/flutter_adaptive_scaffold/example/lib/main.dart index 2afffb773b7f..7793e32335df 100644 --- a/packages/flutter_adaptive_scaffold/example/lib/main.dart +++ b/packages/flutter_adaptive_scaffold/example/lib/main.dart @@ -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(), @@ -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), @@ -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), diff --git a/packages/flutter_adaptive_scaffold/lib/src/adaptive_layout.dart b/packages/flutter_adaptive_scaffold/lib/src/adaptive_layout.dart index f32a8e759bb5..50fd625917c0 100644 --- a/packages/flutter_adaptive_scaffold/lib/src/adaptive_layout.dart +++ b/packages/flutter_adaptive_scaffold/lib/src/adaptive_layout.dart @@ -293,7 +293,7 @@ class _AdaptiveLayoutState extends State }); 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) { diff --git a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart index 3454192037ed..e8b8832054a8 100644 --- a/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart +++ b/packages/flutter_adaptive_scaffold/lib/src/adaptive_scaffold.dart @@ -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( diff --git a/packages/flutter_adaptive_scaffold/pubspec.yaml b/packages/flutter_adaptive_scaffold/pubspec.yaml index 4caf326d2c88..258d9bcc6a7d 100644 --- a/packages/flutter_adaptive_scaffold/pubspec.yaml +++ b/packages/flutter_adaptive_scaffold/pubspec.yaml @@ -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 diff --git a/packages/flutter_adaptive_scaffold/test/adaptive_layout_test.dart b/packages/flutter_adaptive_scaffold/test/adaptive_layout_test.dart index d01119527d05..d2104e3640f0 100644 --- a/packages/flutter_adaptive_scaffold/test/adaptive_layout_test.dart +++ b/packages/flutter_adaptive_scaffold/test/adaptive_layout_test.dart @@ -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; } } diff --git a/packages/flutter_adaptive_scaffold/test/test_breakpoints.dart b/packages/flutter_adaptive_scaffold/test/test_breakpoints.dart index ef94b2f2aa23..ea51ca637e8d 100644 --- a/packages/flutter_adaptive_scaffold/test/test_breakpoints.dart +++ b/packages/flutter_adaptive_scaffold/test/test_breakpoints.dart @@ -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; } }