diff --git a/README.md b/README.md index 4144bfa..d7ff116 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ Container( What if you ONLY want to update the padding based on the device screen size. You could do. ```dart -var deviceType = getDeviceType(MediaQuery.of(context).size); +var deviceType = getDeviceType(MediaQuery.sizeOf(context)); var paddingValue = 0; switch(deviceType) { case DeviceScreenType.desktop: diff --git a/example/lib/views/home/home_view_tablet.dart b/example/lib/views/home/home_view_tablet.dart index 7ad1e95..aba777a 100644 --- a/example/lib/views/home/home_view_tablet.dart +++ b/example/lib/views/home/home_view_tablet.dart @@ -12,7 +12,7 @@ class HomeViewTablet extends StatelessWidget { ), AppDrawer() ]; - var orientation = MediaQuery.of(context).orientation; + var orientation = MediaQuery.orientationOf(context); return Scaffold( body: orientation == Orientation.portrait ? Column(children: children) diff --git a/example/lib/widgets/app_drawer/app_drawer_mobile.dart b/example/lib/widgets/app_drawer/app_drawer_mobile.dart index 3b98a83..e2e31a5 100644 --- a/example/lib/widgets/app_drawer/app_drawer_mobile.dart +++ b/example/lib/widgets/app_drawer/app_drawer_mobile.dart @@ -7,7 +7,7 @@ class AppDrawerMobile extends StatelessWidget { @override Widget build(BuildContext context) { - var orientation = MediaQuery.of(context).orientation; + var orientation = MediaQuery.orientationOf(context); return Container( width: orientation == Orientation.portrait ? 250 : 100, decoration: BoxDecoration(color: Colors.white, boxShadow: [ diff --git a/lib/src/helpers.dart b/lib/src/helpers.dart index ddf355c..7bd683e 100644 --- a/lib/src/helpers.dart +++ b/lib/src/helpers.dart @@ -177,7 +177,7 @@ T getValueForScreenType({ T? desktop, T? watch, }) { - var deviceScreenType = getDeviceType(MediaQuery.of(context).size); + var deviceScreenType = getDeviceType(MediaQuery.sizeOf(context)); // If we're at desktop size if (deviceScreenType == DeviceScreenType.desktop) { // If we have supplied the desktop layout then display that @@ -212,7 +212,7 @@ T getValueForRefinedSize({ T? extraLarge, T? small, }) { - var refinedSize = getRefinedSize(MediaQuery.of(context).size); + var refinedSize = getRefinedSize(MediaQuery.sizeOf(context)); // If we're at extra large size if (refinedSize == RefinedSize.extraLarge) { // If we have supplied the extra large layout then display that diff --git a/lib/src/widget_builders.dart b/lib/src/widget_builders.dart index 8505578..30a612a 100644 --- a/lib/src/widget_builders.dart +++ b/lib/src/widget_builders.dart @@ -26,14 +26,14 @@ class ResponsiveBuilder extends StatelessWidget { @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, boxConstraints) { - var mediaQuery = MediaQuery.of(context); + var size = MediaQuery.sizeOf(context); var sizingInformation = SizingInformation( - deviceScreenType: getDeviceType(mediaQuery.size, breakpoints), + deviceScreenType: getDeviceType(size, breakpoints), refinedSize: getRefinedSize( - mediaQuery.size, + size, refinedBreakpoint: refinedBreakpoints, ), - screenSize: mediaQuery.size, + screenSize: size, localWidgetSize: Size(boxConstraints.maxWidth, boxConstraints.maxHeight), ); @@ -65,7 +65,7 @@ class OrientationLayoutBuilder extends StatelessWidget { Widget build(BuildContext context) { return Builder( builder: (context) { - var orientation = MediaQuery.of(context).orientation; + var orientation = MediaQuery.orientationOf(context); if (mode != OrientationLayoutBuilderMode.portrait && (orientation == Orientation.landscape || mode == OrientationLayoutBuilderMode.landscape)) {