Jonny Borges
Committed by GitHub

Merge pull request #2047 from jonataslaw/mediaquery-update

use inheritedMediaQuery
No preview for this file type
1 import 'package:flutter/cupertino.dart'; 1 import 'package:flutter/cupertino.dart';
2 import 'package:flutter/foundation.dart'; 2 import 'package:flutter/foundation.dart';
3 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
  4 +
4 import '../../../get_core/get_core.dart'; 5 import '../../../get_core/get_core.dart';
5 import '../../../get_instance/get_instance.dart'; 6 import '../../../get_instance/get_instance.dart';
6 import '../../../get_state_manager/get_state_manager.dart'; 7 import '../../../get_state_manager/get_state_manager.dart';
@@ -9,6 +10,59 @@ import '../../get_navigation.dart'; @@ -9,6 +10,59 @@ import '../../get_navigation.dart';
9 import 'root_controller.dart'; 10 import 'root_controller.dart';
10 11
11 class GetCupertinoApp extends StatelessWidget { 12 class GetCupertinoApp extends StatelessWidget {
  13 + final GlobalKey<NavigatorState>? navigatorKey;
  14 +
  15 + final Widget? home;
  16 + final Map<String, WidgetBuilder>? routes;
  17 + final String? initialRoute;
  18 + final RouteFactory? onGenerateRoute;
  19 + final InitialRouteListFactory? onGenerateInitialRoutes;
  20 + final RouteFactory? onUnknownRoute;
  21 + final List<NavigatorObserver>? navigatorObservers;
  22 + final TransitionBuilder? builder;
  23 + final String title;
  24 + final GenerateAppTitle? onGenerateTitle;
  25 + final CustomTransition? customTransition;
  26 + final Color? color;
  27 + final Map<String, Map<String, String>>? translationsKeys;
  28 + final Translations? translations;
  29 + final TextDirection? textDirection;
  30 + final Locale? locale;
  31 + final Locale? fallbackLocale;
  32 + final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates;
  33 + final LocaleListResolutionCallback? localeListResolutionCallback;
  34 + final LocaleResolutionCallback? localeResolutionCallback;
  35 + final Iterable<Locale> supportedLocales;
  36 + final bool showPerformanceOverlay;
  37 + final bool checkerboardRasterCacheImages;
  38 + final bool checkerboardOffscreenLayers;
  39 + final bool showSemanticsDebugger;
  40 + final bool debugShowCheckedModeBanner;
  41 + final Map<LogicalKeySet, Intent>? shortcuts;
  42 + final ThemeData? highContrastTheme;
  43 + final ThemeData? highContrastDarkTheme;
  44 + final Map<Type, Action<Intent>>? actions;
  45 + final Function(Routing?)? routingCallback;
  46 + final Transition? defaultTransition;
  47 + final bool? opaqueRoute;
  48 + final VoidCallback? onInit;
  49 + final VoidCallback? onReady;
  50 + final VoidCallback? onDispose;
  51 + final bool? enableLog;
  52 + final LogWriterCallback? logWriterCallback;
  53 + final bool? popGesture;
  54 + final SmartManagement smartManagement;
  55 + final Bindings? initialBinding;
  56 + final Duration? transitionDuration;
  57 + final bool? defaultGlobalState;
  58 + final List<GetPage>? getPages;
  59 + final GetPage? unknownRoute;
  60 + final RouteInformationProvider? routeInformationProvider;
  61 + final RouteInformationParser<Object>? routeInformationParser;
  62 + final RouterDelegate<Object>? routerDelegate;
  63 + final BackButtonDispatcher? backButtonDispatcher;
  64 + final CupertinoThemeData? theme;
  65 + final bool useInheritedMediaQuery;
12 const GetCupertinoApp({ 66 const GetCupertinoApp({
13 Key? key, 67 Key? key,
14 this.theme, 68 this.theme,
@@ -46,6 +100,7 @@ class GetCupertinoApp extends StatelessWidget { @@ -46,6 +100,7 @@ class GetCupertinoApp extends StatelessWidget {
46 this.shortcuts, 100 this.shortcuts,
47 this.smartManagement = SmartManagement.full, 101 this.smartManagement = SmartManagement.full,
48 this.initialBinding, 102 this.initialBinding,
  103 + this.useInheritedMediaQuery = false,
49 this.unknownRoute, 104 this.unknownRoute,
50 this.routingCallback, 105 this.routingCallback,
51 this.defaultTransition, 106 this.defaultTransition,
@@ -66,58 +121,6 @@ class GetCupertinoApp extends StatelessWidget { @@ -66,58 +121,6 @@ class GetCupertinoApp extends StatelessWidget {
66 backButtonDispatcher = null, 121 backButtonDispatcher = null,
67 super(key: key); 122 super(key: key);
68 123
69 - final GlobalKey<NavigatorState>? navigatorKey;  
70 - final Widget? home;  
71 - final Map<String, WidgetBuilder>? routes;  
72 - final String? initialRoute;  
73 - final RouteFactory? onGenerateRoute;  
74 - final InitialRouteListFactory? onGenerateInitialRoutes;  
75 - final RouteFactory? onUnknownRoute;  
76 - final List<NavigatorObserver>? navigatorObservers;  
77 - final TransitionBuilder? builder;  
78 - final String title;  
79 - final GenerateAppTitle? onGenerateTitle;  
80 - final CustomTransition? customTransition;  
81 - final Color? color;  
82 - final Map<String, Map<String, String>>? translationsKeys;  
83 - final Translations? translations;  
84 - final TextDirection? textDirection;  
85 - final Locale? locale;  
86 - final Locale? fallbackLocale;  
87 - final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates;  
88 - final LocaleListResolutionCallback? localeListResolutionCallback;  
89 - final LocaleResolutionCallback? localeResolutionCallback;  
90 - final Iterable<Locale> supportedLocales;  
91 - final bool showPerformanceOverlay;  
92 - final bool checkerboardRasterCacheImages;  
93 - final bool checkerboardOffscreenLayers;  
94 - final bool showSemanticsDebugger;  
95 - final bool debugShowCheckedModeBanner;  
96 - final Map<LogicalKeySet, Intent>? shortcuts;  
97 - final ThemeData? highContrastTheme;  
98 - final ThemeData? highContrastDarkTheme;  
99 - final Map<Type, Action<Intent>>? actions;  
100 - final Function(Routing?)? routingCallback;  
101 - final Transition? defaultTransition;  
102 - final bool? opaqueRoute;  
103 - final VoidCallback? onInit;  
104 - final VoidCallback? onReady;  
105 - final VoidCallback? onDispose;  
106 - final bool? enableLog;  
107 - final LogWriterCallback? logWriterCallback;  
108 - final bool? popGesture;  
109 - final SmartManagement smartManagement;  
110 - final Bindings? initialBinding;  
111 - final Duration? transitionDuration;  
112 - final bool? defaultGlobalState;  
113 - final List<GetPage>? getPages;  
114 - final GetPage? unknownRoute;  
115 - final RouteInformationProvider? routeInformationProvider;  
116 - final RouteInformationParser<Object>? routeInformationParser;  
117 - final RouterDelegate<Object>? routerDelegate;  
118 - final BackButtonDispatcher? backButtonDispatcher;  
119 - final CupertinoThemeData? theme;  
120 -  
121 GetCupertinoApp.router({ 124 GetCupertinoApp.router({
122 Key? key, 125 Key? key,
123 this.theme, 126 this.theme,
@@ -128,6 +131,7 @@ class GetCupertinoApp extends StatelessWidget { @@ -128,6 +131,7 @@ class GetCupertinoApp extends StatelessWidget {
128 this.builder, 131 this.builder,
129 this.title = '', 132 this.title = '',
130 this.onGenerateTitle, 133 this.onGenerateTitle,
  134 + this.useInheritedMediaQuery = false,
131 this.color, 135 this.color,
132 this.highContrastTheme, 136 this.highContrastTheme,
133 this.highContrastDarkTheme, 137 this.highContrastDarkTheme,
@@ -183,31 +187,6 @@ class GetCupertinoApp extends StatelessWidget { @@ -183,31 +187,6 @@ class GetCupertinoApp extends StatelessWidget {
183 Get.routeInformationParser = routeInformationParser; 187 Get.routeInformationParser = routeInformationParser;
184 } 188 }
185 189
186 - Route<dynamic> generator(RouteSettings settings) {  
187 - return PageRedirect(settings: settings, unknownRoute: unknownRoute).page();  
188 - }  
189 -  
190 - List<Route<dynamic>> initialRoutesGenerate(String name) {  
191 - return [  
192 - PageRedirect(  
193 - settings: RouteSettings(name: name),  
194 - unknownRoute: unknownRoute,  
195 - ).page()  
196 - ];  
197 - }  
198 -  
199 - Widget defaultBuilder(BuildContext context, Widget? child) {  
200 - return Directionality(  
201 - textDirection: textDirection ??  
202 - (rtlLanguages.contains(Get.locale?.languageCode)  
203 - ? TextDirection.rtl  
204 - : TextDirection.ltr),  
205 - child: builder == null  
206 - ? (child ?? Material())  
207 - : builder!(context, child ?? Material()),  
208 - );  
209 - }  
210 -  
211 @override 190 @override
212 Widget build(BuildContext context) => GetBuilder<GetMaterialController>( 191 Widget build(BuildContext context) => GetBuilder<GetMaterialController>(
213 init: Get.rootController, 192 init: Get.rootController,
@@ -271,6 +250,7 @@ class GetCupertinoApp extends StatelessWidget { @@ -271,6 +250,7 @@ class GetCupertinoApp extends StatelessWidget {
271 showSemanticsDebugger: showSemanticsDebugger, 250 showSemanticsDebugger: showSemanticsDebugger,
272 debugShowCheckedModeBanner: debugShowCheckedModeBanner, 251 debugShowCheckedModeBanner: debugShowCheckedModeBanner,
273 shortcuts: shortcuts, 252 shortcuts: shortcuts,
  253 + useInheritedMediaQuery: useInheritedMediaQuery,
274 ) 254 )
275 : CupertinoApp( 255 : CupertinoApp(
276 key: _.unikey, 256 key: _.unikey,
@@ -310,7 +290,33 @@ class GetCupertinoApp extends StatelessWidget { @@ -310,7 +290,33 @@ class GetCupertinoApp extends StatelessWidget {
310 showSemanticsDebugger: showSemanticsDebugger, 290 showSemanticsDebugger: showSemanticsDebugger,
311 debugShowCheckedModeBanner: debugShowCheckedModeBanner, 291 debugShowCheckedModeBanner: debugShowCheckedModeBanner,
312 shortcuts: shortcuts, 292 shortcuts: shortcuts,
  293 + useInheritedMediaQuery: useInheritedMediaQuery,
313 // actions: actions, 294 // actions: actions,
314 ), 295 ),
315 ); 296 );
  297 +
  298 + Widget defaultBuilder(BuildContext context, Widget? child) {
  299 + return Directionality(
  300 + textDirection: textDirection ??
  301 + (rtlLanguages.contains(Get.locale?.languageCode)
  302 + ? TextDirection.rtl
  303 + : TextDirection.ltr),
  304 + child: builder == null
  305 + ? (child ?? Material())
  306 + : builder!(context, child ?? Material()),
  307 + );
  308 + }
  309 +
  310 + Route<dynamic> generator(RouteSettings settings) {
  311 + return PageRedirect(settings: settings, unknownRoute: unknownRoute).page();
  312 + }
  313 +
  314 + List<Route<dynamic>> initialRoutesGenerate(String name) {
  315 + return [
  316 + PageRedirect(
  317 + settings: RouteSettings(name: name),
  318 + unknownRoute: unknownRoute,
  319 + ).page()
  320 + ];
  321 + }
316 } 322 }
@@ -67,6 +67,7 @@ class GetMaterialApp extends StatelessWidget { @@ -67,6 +67,7 @@ class GetMaterialApp extends StatelessWidget {
67 final RouteInformationParser<Object>? routeInformationParser; 67 final RouteInformationParser<Object>? routeInformationParser;
68 final RouterDelegate<Object>? routerDelegate; 68 final RouterDelegate<Object>? routerDelegate;
69 final BackButtonDispatcher? backButtonDispatcher; 69 final BackButtonDispatcher? backButtonDispatcher;
  70 + final bool useInheritedMediaQuery;
70 const GetMaterialApp({ 71 const GetMaterialApp({
71 Key? key, 72 Key? key,
72 this.navigatorKey, 73 this.navigatorKey,
@@ -78,6 +79,7 @@ class GetMaterialApp extends StatelessWidget { @@ -78,6 +79,7 @@ class GetMaterialApp extends StatelessWidget {
78 this.onGenerateRoute, 79 this.onGenerateRoute,
79 this.onGenerateInitialRoutes, 80 this.onGenerateInitialRoutes,
80 this.onUnknownRoute, 81 this.onUnknownRoute,
  82 + this.useInheritedMediaQuery = false,
81 List<NavigatorObserver> this.navigatorObservers = 83 List<NavigatorObserver> this.navigatorObservers =
82 const <NavigatorObserver>[], 84 const <NavigatorObserver>[],
83 this.builder, 85 this.builder,
@@ -142,6 +144,7 @@ class GetMaterialApp extends StatelessWidget { @@ -142,6 +144,7 @@ class GetMaterialApp extends StatelessWidget {
142 this.color, 144 this.color,
143 this.theme, 145 this.theme,
144 this.darkTheme, 146 this.darkTheme,
  147 + this.useInheritedMediaQuery = false,
145 this.highContrastTheme, 148 this.highContrastTheme,
146 this.highContrastDarkTheme, 149 this.highContrastDarkTheme,
147 this.themeMode = ThemeMode.system, 150 this.themeMode = ThemeMode.system,
@@ -271,6 +274,7 @@ class GetMaterialApp extends StatelessWidget { @@ -271,6 +274,7 @@ class GetMaterialApp extends StatelessWidget {
271 debugShowCheckedModeBanner: debugShowCheckedModeBanner, 274 debugShowCheckedModeBanner: debugShowCheckedModeBanner,
272 shortcuts: shortcuts, 275 shortcuts: shortcuts,
273 scrollBehavior: scrollBehavior, 276 scrollBehavior: scrollBehavior,
  277 + useInheritedMediaQuery: useInheritedMediaQuery,
274 ) 278 )
275 : MaterialApp( 279 : MaterialApp(
276 key: _.unikey, 280 key: _.unikey,
@@ -317,6 +321,7 @@ class GetMaterialApp extends StatelessWidget { @@ -317,6 +321,7 @@ class GetMaterialApp extends StatelessWidget {
317 debugShowCheckedModeBanner: debugShowCheckedModeBanner, 321 debugShowCheckedModeBanner: debugShowCheckedModeBanner,
318 shortcuts: shortcuts, 322 shortcuts: shortcuts,
319 scrollBehavior: scrollBehavior, 323 scrollBehavior: scrollBehavior,
  324 + useInheritedMediaQuery: useInheritedMediaQuery,
320 // actions: actions, 325 // actions: actions,
321 ), 326 ),
322 ); 327 );