Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
flutter_screenutil
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
李卓原
2023-05-11 11:44:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
43300ed24a246b759333c3232be43b1a0102710c
43300ed2
1 parent
d89513f4
尝试替换init时context的选择
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
27 deletions
example/lib/generated_plugin_registrant.dart
lib/src/screen_util.dart
example/lib/generated_plugin_registrant.dart
deleted
100644 → 0
View file @
d89513f
//
// Generated file. Do not edit.
//
// ignore_for_file: directives_ordering
// ignore_for_file: lines_longer_than_80_chars
import
'package:shared_preferences_web/shared_preferences_web.dart'
;
import
'package:flutter_web_plugins/flutter_web_plugins.dart'
;
// ignore: public_member_api_docs
void
registerPlugins
(
Registrar
registrar
)
{
SharedPreferencesPlugin
.
registerWith
(
registrar
);
registrar
.
registerMessageHandler
();
}
lib/src/screen_util.dart
View file @
43300ed
...
...
@@ -89,16 +89,17 @@ class ScreenUtil {
}
/// Initializing the library.
static
Future
<
void
>
init
(
BuildContext
context
,
{
Size
designSize
=
defaultSize
,
bool
splitScreenMode
=
false
,
bool
minTextAdapt
=
false
,
bool
scaleByHeight
=
false
})
async
{
final
navigatorContext
=
Navigator
.
maybeOf
(
context
)?.
context
as
Element
?;
static
Future
<
void
>
init
(
BuildContext
context
,
{
Size
designSize
=
defaultSize
,
bool
splitScreenMode
=
false
,
bool
minTextAdapt
=
false
,
bool
scaleByHeight
=
false
})
async
{
//todo 考虑直接使用context
// final navigatorContext = Navigator.maybeOf(context)?.context as Element?;
// final mediaQueryContext =
// navigatorContext?.getElementForInheritedWidgetOfExactType<MediaQuery>();
final
mediaQueryContext
=
navigatorContext
?
.
getElementForInheritedWidgetOfExactType
<
MediaQuery
>();
context
.
getElementForInheritedWidgetOfExactType
<
MediaQuery
>();
final
initCompleter
=
Completer
<
void
>();
...
...
@@ -121,8 +122,9 @@ class ScreenUtil {
..
_splitScreenMode
=
splitScreenMode
..
_minTextAdapt
=
minTextAdapt
..
_orientation
=
orientation
..
_screenWidth
=
scaleByHeight
?
(
deviceSize
.
height
*
designSize
.
width
)
/
designSize
.
height
:
deviceSize
.
width
..
_screenWidth
=
scaleByHeight
?
(
deviceSize
.
height
*
designSize
.
width
)
/
designSize
.
height
:
deviceSize
.
width
..
_screenHeight
=
deviceSize
.
height
;
_instance
.
_elementsToRebuild
?.
forEach
((
el
)
=>
el
.
markNeedsBuild
());
...
...
Please
register
or
login
to post a comment