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
Mounir Bouaiche
2023-06-11 20:41:14 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
79aac75bd7bb3f08715824035c9427f9337279e4
79aac75b
1 parent
99c24dd0
Add option for how font size should be scaled
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletions
lib/src/screen_util.dart
lib/src/screen_util.dart
View file @
79aac75
...
...
@@ -8,6 +8,8 @@ import 'dart:ui' as ui show FlutterView;
import
'package:flutter/widgets.dart'
;
typedef
FontSizeResolver
=
double
Function
(
num
fontSize
,
ScreenUtil
instance
);
class
ScreenUtil
{
static
const
Size
defaultSize
=
Size
(
360
,
690
);
static
ScreenUtil
_instance
=
ScreenUtil
.
_
();
...
...
@@ -22,6 +24,7 @@ class ScreenUtil {
late
bool
_minTextAdapt
;
late
MediaQueryData
_data
;
late
bool
_splitScreenMode
;
FontSizeResolver
?
fontSizeResolver
;
ScreenUtil
.
_
();
...
...
@@ -95,6 +98,7 @@ class ScreenUtil {
bool
?
splitScreenMode
,
bool
?
minTextAdapt
,
bool
?
ensureScreenHasSize
,
FontSizeResolver
?
fontSizeResolver
,
})
async
{
if
(
ensureScreenHasSize
??
false
)
await
ScreenUtil
.
ensureScreenSize
();
...
...
@@ -122,6 +126,7 @@ class ScreenUtil {
:
Orientation
.
portrait
);
_instance
..
fontSizeResolver
=
fontSizeResolver
??
_instance
.
fontSizeResolver
..
_minTextAdapt
=
minTextAdapt
??
_instance
.
_minTextAdapt
..
_splitScreenMode
=
splitScreenMode
??
_instance
.
_splitScreenMode
..
_orientation
=
orientation
;
...
...
@@ -136,6 +141,7 @@ class ScreenUtil {
bool
splitScreenMode
=
false
,
bool
minTextAdapt
=
false
,
bool
ensureScreenSize
=
false
,
FontSizeResolver
?
fontSizeResolver
,
})
{
return
configure
(
data:
MediaQuery
.
maybeOf
(
context
),
...
...
@@ -143,6 +149,7 @@ class ScreenUtil {
minTextAdapt:
minTextAdapt
,
splitScreenMode:
splitScreenMode
,
ensureScreenHasSize:
ensureScreenSize
,
fontSizeResolver:
fontSizeResolver
,
);
}
...
...
@@ -217,7 +224,8 @@ class ScreenUtil {
///- [fontSize] UI设计上字体的大小,单位dp.
///Font size adaptation method
///- [fontSize] The size of the font on the UI design, in dp.
double
setSp
(
num
fontSize
)
=>
fontSize
*
scaleText
;
double
setSp
(
num
fontSize
)
=>
fontSizeResolver
?.
call
(
fontSize
,
_instance
)
??
fontSize
*
scaleText
;
Widget
setVerticalSpacing
(
num
height
)
=>
SizedBox
(
height:
setHeight
(
height
));
...
...
Please
register
or
login
to post a comment