@@ -27,52 +27,13 @@ class Device
27
27
DeviceInfoCapability ,
28
28
WidgetsBindingObserver {
29
29
static final Device _instance = Device ._internal ();
30
- static late BuildContext context;
31
30
32
- Device ._internal () {
33
- WidgetsBinding .instance.addObserver (this );
34
- }
31
+ Device ._internal ();
35
32
36
- factory Device ([BuildContext ? buildContext]) {
37
- if (buildContext != null ) {
38
- context = buildContext;
39
- }
33
+ factory Device () {
40
34
return _instance;
41
35
}
42
36
43
- // method to update context
44
- void updateContext (BuildContext ? newContext) {
45
- if (newContext != null ) {
46
- context = newContext;
47
- }
48
- }
49
-
50
- @override
51
- void didChangeMetrics () {
52
- WidgetsBinding .instance
53
- .addPostFrameCallback ((_) => _handleMediaQueryChange ());
54
- }
55
-
56
- void _handleMediaQueryChange () {
57
- final newData = MediaQuery .of (context);
58
-
59
- // Compare with existing static data
60
- if (MediaQueryCapability .data? .orientation != newData.orientation ||
61
- MediaQueryCapability .data? .size != newData.size) {
62
- MediaQueryCapability .data = newData;
63
-
64
- // Dispatch individual property changes
65
- ScreenController ().dispatchDeviceChanges (context, 'width' , screenWidth);
66
- ScreenController ().dispatchDeviceChanges (context, 'height' , screenHeight);
67
- ScreenController ()
68
- .dispatchDeviceChanges (context, 'orientation' , screenOrientation);
69
- ScreenController ()
70
- .dispatchDeviceChanges (context, 'safeAreaTop' , safeAreaTop);
71
- ScreenController ()
72
- .dispatchDeviceChanges (context, 'safeAreaBottom' , safeAreaBottom);
73
- }
74
- }
75
-
76
37
@override
77
38
Map <String , Function > getters () {
78
39
return {
0 commit comments