Showing
2 changed files
with
11 additions
and
25 deletions
| 1 | -// | ||
| 2 | -// Generated file. Do not edit. | ||
| 3 | -// | ||
| 4 | - | ||
| 5 | -// ignore_for_file: directives_ordering | ||
| 6 | -// ignore_for_file: lines_longer_than_80_chars | ||
| 7 | - | ||
| 8 | -import 'package:shared_preferences_web/shared_preferences_web.dart'; | ||
| 9 | - | ||
| 10 | -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; | ||
| 11 | - | ||
| 12 | -// ignore: public_member_api_docs | ||
| 13 | -void registerPlugins(Registrar registrar) { | ||
| 14 | - SharedPreferencesPlugin.registerWith(registrar); | ||
| 15 | - registrar.registerMessageHandler(); | ||
| 16 | -} |
| @@ -89,16 +89,17 @@ class ScreenUtil { | @@ -89,16 +89,17 @@ class ScreenUtil { | ||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | /// Initializing the library. | 91 | /// Initializing the library. |
| 92 | - static Future<void> init( | ||
| 93 | - BuildContext context, { | ||
| 94 | - Size designSize = defaultSize, | 92 | + static Future<void> init(BuildContext context, |
| 93 | + {Size designSize = defaultSize, | ||
| 95 | bool splitScreenMode = false, | 94 | bool splitScreenMode = false, |
| 96 | bool minTextAdapt = false, | 95 | bool minTextAdapt = false, |
| 97 | - bool scaleByHeight = false | ||
| 98 | - }) async { | ||
| 99 | - final navigatorContext = Navigator.maybeOf(context)?.context as Element?; | 96 | + bool scaleByHeight = false}) async { |
| 97 | + //todo 考虑直接使用context | ||
| 98 | + // final navigatorContext = Navigator.maybeOf(context)?.context as Element?; | ||
| 99 | + // final mediaQueryContext = | ||
| 100 | + // navigatorContext?.getElementForInheritedWidgetOfExactType<MediaQuery>(); | ||
| 100 | final mediaQueryContext = | 101 | final mediaQueryContext = |
| 101 | - navigatorContext?.getElementForInheritedWidgetOfExactType<MediaQuery>(); | 102 | + context.getElementForInheritedWidgetOfExactType<MediaQuery>(); |
| 102 | 103 | ||
| 103 | final initCompleter = Completer<void>(); | 104 | final initCompleter = Completer<void>(); |
| 104 | 105 | ||
| @@ -121,8 +122,9 @@ class ScreenUtil { | @@ -121,8 +122,9 @@ class ScreenUtil { | ||
| 121 | .._splitScreenMode = splitScreenMode | 122 | .._splitScreenMode = splitScreenMode |
| 122 | .._minTextAdapt = minTextAdapt | 123 | .._minTextAdapt = minTextAdapt |
| 123 | .._orientation = orientation | 124 | .._orientation = orientation |
| 124 | - .._screenWidth = scaleByHeight ? (deviceSize.height * designSize.width) / | ||
| 125 | - designSize.height : deviceSize.width | 125 | + .._screenWidth = scaleByHeight |
| 126 | + ? (deviceSize.height * designSize.width) / designSize.height | ||
| 127 | + : deviceSize.width | ||
| 126 | .._screenHeight = deviceSize.height; | 128 | .._screenHeight = deviceSize.height; |
| 127 | 129 | ||
| 128 | _instance._elementsToRebuild?.forEach((el) => el.markNeedsBuild()); | 130 | _instance._elementsToRebuild?.forEach((el) => el.markNeedsBuild()); |
-
Please register or login to post a comment