Committed by
GitHub
Merge pull request #2854 from dhruvanbhalara/migrate/context_extensions
refactor: migrate MediaQuery `context_extensions` to InheritedModel
Showing
2 changed files
with
21 additions
and
21 deletions
@@ -680,19 +680,19 @@ context.height | @@ -680,19 +680,19 @@ context.height | ||
680 | context.heightTransformer() | 680 | context.heightTransformer() |
681 | context.widthTransformer() | 681 | context.widthTransformer() |
682 | 682 | ||
683 | -/// Similar to MediaQuery.of(context).size | 683 | +/// Similar to MediaQuery.sizeOf(context); |
684 | context.mediaQuerySize() | 684 | context.mediaQuerySize() |
685 | 685 | ||
686 | -/// Similar to MediaQuery.of(context).padding | 686 | +/// Similar to MediaQuery.paddingOf(context); |
687 | context.mediaQueryPadding() | 687 | context.mediaQueryPadding() |
688 | 688 | ||
689 | -/// Similar to MediaQuery.of(context).viewPadding | 689 | +/// Similar to MediaQuery.viewPaddingOf(context); |
690 | context.mediaQueryViewPadding() | 690 | context.mediaQueryViewPadding() |
691 | 691 | ||
692 | -/// Similar to MediaQuery.of(context).viewInsets; | 692 | +/// Similar to MediaQuery.viewInsetsOf(context); |
693 | context.mediaQueryViewInsets() | 693 | context.mediaQueryViewInsets() |
694 | 694 | ||
695 | -/// Similar to MediaQuery.of(context).orientation; | 695 | +/// Similar to MediaQuery.orientationOf(context); |
696 | context.orientation() | 696 | context.orientation() |
697 | 697 | ||
698 | /// Check if device is on landscape mode | 698 | /// Check if device is on landscape mode |
@@ -701,10 +701,10 @@ context.isLandscape() | @@ -701,10 +701,10 @@ context.isLandscape() | ||
701 | /// Check if device is on portrait mode | 701 | /// Check if device is on portrait mode |
702 | context.isPortrait() | 702 | context.isPortrait() |
703 | 703 | ||
704 | -/// Similar to MediaQuery.of(context).devicePixelRatio; | 704 | +/// Similar to MediaQuery.devicePixelRatioOf(context); |
705 | context.devicePixelRatio() | 705 | context.devicePixelRatio() |
706 | 706 | ||
707 | -/// Similar to MediaQuery.of(context).textScaleFactor; | 707 | +/// Similar to MediaQuery.textScaleFactorOf(context); |
708 | context.textScaleFactor() | 708 | context.textScaleFactor() |
709 | 709 | ||
710 | /// Get the shortestSide from screen | 710 | /// Get the shortestSide from screen |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | 2 | ||
3 | extension ContextExt on BuildContext { | 3 | extension ContextExt on BuildContext { |
4 | - /// The same of [MediaQuery.of(context).size] | ||
5 | - Size get mediaQuerySize => MediaQuery.of(this).size; | 4 | + /// The same of [MediaQuery.sizeOf(context)] |
5 | + Size get mediaQuerySize => MediaQuery.sizeOf(this); | ||
6 | 6 | ||
7 | /// The same of [MediaQuery.of(context).size.height] | 7 | /// The same of [MediaQuery.of(context).size.height] |
8 | /// Note: updates when you rezise your screen (like on a browser or | 8 | /// Note: updates when you rezise your screen (like on a browser or |
@@ -65,20 +65,20 @@ extension ContextExt on BuildContext { | @@ -65,20 +65,20 @@ extension ContextExt on BuildContext { | ||
65 | /// similar to [MediaQuery.of(context).padding] | 65 | /// similar to [MediaQuery.of(context).padding] |
66 | TextTheme get textTheme => Theme.of(this).textTheme; | 66 | TextTheme get textTheme => Theme.of(this).textTheme; |
67 | 67 | ||
68 | - /// similar to [MediaQuery.of(context).padding] | ||
69 | - EdgeInsets get mediaQueryPadding => MediaQuery.of(this).padding; | 68 | + /// similar to [MediaQuery.paddingOf(context)] |
69 | + EdgeInsets get mediaQueryPadding => MediaQuery.paddingOf(this); | ||
70 | 70 | ||
71 | /// similar to [MediaQuery.of(context).padding] | 71 | /// similar to [MediaQuery.of(context).padding] |
72 | MediaQueryData get mediaQuery => MediaQuery.of(this); | 72 | MediaQueryData get mediaQuery => MediaQuery.of(this); |
73 | 73 | ||
74 | - /// similar to [MediaQuery.of(context).viewPadding] | ||
75 | - EdgeInsets get mediaQueryViewPadding => MediaQuery.of(this).viewPadding; | 74 | + /// similar to [MediaQuery.viewPaddingOf(context)] |
75 | + EdgeInsets get mediaQueryViewPadding => MediaQuery.viewPaddingOf(this); | ||
76 | 76 | ||
77 | - /// similar to [MediaQuery.of(context).viewInsets] | ||
78 | - EdgeInsets get mediaQueryViewInsets => MediaQuery.of(this).viewInsets; | 77 | + /// similar to [MediaQuery.viewInsetsOf(context)] |
78 | + EdgeInsets get mediaQueryViewInsets => MediaQuery.viewInsetsOf(this); | ||
79 | 79 | ||
80 | - /// similar to [MediaQuery.of(context).orientation] | ||
81 | - Orientation get orientation => MediaQuery.of(this).orientation; | 80 | + /// similar to [MediaQuery.orientationOf(context)] |
81 | + Orientation get orientation => MediaQuery.orientationOf(this); | ||
82 | 82 | ||
83 | /// check if device is on landscape mode | 83 | /// check if device is on landscape mode |
84 | bool get isLandscape => orientation == Orientation.landscape; | 84 | bool get isLandscape => orientation == Orientation.landscape; |
@@ -86,11 +86,11 @@ extension ContextExt on BuildContext { | @@ -86,11 +86,11 @@ extension ContextExt on BuildContext { | ||
86 | /// check if device is on portrait mode | 86 | /// check if device is on portrait mode |
87 | bool get isPortrait => orientation == Orientation.portrait; | 87 | bool get isPortrait => orientation == Orientation.portrait; |
88 | 88 | ||
89 | - /// similar to [MediaQuery.of(this).devicePixelRatio] | ||
90 | - double get devicePixelRatio => MediaQuery.of(this).devicePixelRatio; | 89 | + /// similar to [MediaQuery.devicePixelRatioOf(context)] |
90 | + double get devicePixelRatio => MediaQuery.devicePixelRatioOf(this); | ||
91 | 91 | ||
92 | - /// similar to [MediaQuery.of(this).textScaleFactor] | ||
93 | - double get textScaleFactor => MediaQuery.of(this).textScaleFactor; | 92 | + /// similar to [MediaQuery.textScaleFactorOf(context)] |
93 | + double get textScaleFactor => MediaQuery.textScaleFactorOf(this); | ||
94 | 94 | ||
95 | /// get the shortestSide from screen | 95 | /// get the shortestSide from screen |
96 | double get mediaQueryShortestSide => mediaQuerySize.shortestSide; | 96 | double get mediaQueryShortestSide => mediaQuerySize.shortestSide; |
-
Please register or login to post a comment