Dhruvan Bhalara

refactor: migrate `context_extensions` to InheritedModel

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;