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
Simon
2023-11-24 12:49:12 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c31fffe443cd09eaefa4b90eee9daac3e7a5f2bf
c31fffe4
1 parent
b780eb79
feat: support for disabling scaling
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
lib/src/screen_util.dart
lib/src/screen_util.dart
View file @
c31fffe
...
...
@@ -15,6 +15,10 @@ class ScreenUtil {
static
const
Size
defaultSize
=
Size
(
360
,
690
);
static
ScreenUtil
_instance
=
ScreenUtil
.
_
();
static
bool
Function
()
_enableScaleWH
=
()
=>
true
;
static
bool
Function
()
_enableScaleText
=
()
=>
true
;
/// UI设计中手机尺寸 , dp
/// Size of the phone in UI Design , dp
late
Size
_uiSize
;
...
...
@@ -31,6 +35,16 @@ class ScreenUtil {
factory
ScreenUtil
()
=>
_instance
;
/// Enable scale
///
/// if the enableWH return false, the width and the height scale ratio will be 1
/// if the enableText return false, the text scale ratio will be 1
///
static
void
enableScale
({
bool
Function
()?
enableWH
,
bool
Function
()?
enableText
})
{
_enableScaleWH
=
enableWH
??
()
=>
true
;
_enableScaleText
=
enableText
??
()
=>
true
;
}
/// Manually wait for window size to be initialized
///
/// `Recommended` to use before you need access window size
...
...
@@ -197,15 +211,15 @@ class ScreenUtil {
/// 实际尺寸与UI设计的比例
/// The ratio of actual width to UI design
double
get
scaleWidth
=>
screenWidth
/
_uiSize
.
width
;
double
get
scaleWidth
=>
!
_enableScaleWH
()
?
1
:
screenWidth
/
_uiSize
.
width
;
/// The ratio of actual height to UI design
double
get
scaleHeight
=>
(
_splitScreenMode
?
max
(
screenHeight
,
700
)
:
screenHeight
)
/
!
_enableScaleWH
()
?
1
:
(
_splitScreenMode
?
max
(
screenHeight
,
700
)
:
screenHeight
)
/
_uiSize
.
height
;
double
get
scaleText
=>
_minTextAdapt
?
min
(
scaleWidth
,
scaleHeight
)
:
scaleWidth
;
!
_enableScaleText
()
?
1
:
(
_minTextAdapt
?
min
(
scaleWidth
,
scaleHeight
)
:
scaleWidth
)
;
/// 根据UI设计的设备宽度适配
/// 高度也可以根据这个来做适配可以保证不变形,比如你想要一个正方形的时候.
...
...
Please
register
or
login
to post a comment