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
zhuoyuan
2021-12-25 13:31:03 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e35ffdd3bd820adb7466dc2002bd339f63fb884b
e35ffdd3
1 parent
a77e9c32
5.0.2
fix #306
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
10 deletions
CHANGELOG.md
README.md
README_CN.md
README_PT.md
example/lib/main.dart
lib/screen_util.dart
lib/screenutil_init.dart
pubspec.yaml
CHANGELOG.md
View file @
e35ffdd
# 5.0.2
-
add "minTextAdapt" param , Font adaptation is based on the minimum value of width and height or only based on width(default)
-
update readme
# 5.0.1+3
-
fix .r
# 5.0.1+2
-
Text adaptation no longer considers the height of the screen
...
...
README.md
View file @
e35ffdd
...
...
@@ -79,6 +79,7 @@ class MyApp extends StatelessWidget {
//Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp)
return
ScreenUtilInit
(
designSize:
Size
(
360
,
690
),
minTextAdapt:
true
,
builder:
()
=>
MaterialApp
(
...
theme:
ThemeData
(
...
...
@@ -143,6 +144,7 @@ class _HomePageState extends State<HomePage> {
maxWidth:
MediaQuery
.
of
(
context
).
size
.
width
,
maxHeight:
MediaQuery
.
of
(
context
).
size
.
height
),
designSize:
Size
(
360
,
690
),
minTextAdapt:
true
,
orientation:
Orientation
.
portrait
);
return
Scaffold
();
}
...
...
README_CN.md
View file @
e35ffdd
...
...
@@ -60,6 +60,7 @@ class MyApp extends StatelessWidget {
//填入设计稿中设备的屏幕尺寸,单位dp
return
ScreenUtilInit
(
designSize:
Size
(
360
,
690
),
minTextAdapt:
true
,
builder:
()
=>
MaterialApp
(
debugShowCheckedModeBanner:
false
,
title:
'Flutter_ScreenUtil'
,
...
...
@@ -115,6 +116,7 @@ class _HomePageState extends State<HomePage> {
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
minTextAdapt: true,
orientation: Orientation.portrait);
return Scaffold();
}
...
...
README_PT.md
View file @
e35ffdd
...
...
@@ -56,6 +56,7 @@ class MyApp extends StatelessWidget {
//Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp)
return
ScreenUtilInit
(
designSize:
Size
(
360
,
690
),
minTextAdapt:
true
,
builder:
()
=>
MaterialApp
(
...
theme:
ThemeData
(
...
...
example/lib/main.dart
View file @
e35ffdd
...
...
@@ -9,6 +9,7 @@ class MyApp extends StatelessWidget {
//Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the iPhone6 (iPhone6 750*1334)
return
ScreenUtilInit
(
designSize:
Size
(
360
,
690
),
minTextAdapt:
true
,
splitScreenMode:
true
,
builder:
()
=>
MaterialApp
(
debugShowCheckedModeBanner:
false
,
...
...
lib/screen_util.dart
View file @
e35ffdd
...
...
@@ -21,6 +21,7 @@ class ScreenUtil {
late
double
_screenHeight
;
late
double
_statusBarHeight
;
late
double
_bottomBarHeight
;
late
bool
_minTextAdapt
;
ScreenUtil
.
_
();
...
...
@@ -33,14 +34,14 @@ class ScreenUtil {
Orientation
orientation
=
Orientation
.
portrait
,
Size
designSize
=
defaultSize
,
bool
splitScreenMode
=
false
,
bool
minTextAdapt
=
false
,
})
{
_instance
=
ScreenUtil
.
_
()
..
uiSize
=
designSize
..
_minTextAdapt
=
minTextAdapt
..
_orientation
=
orientation
..
_screenWidth
=
constraints
.
maxWidth
..
_screenHeight
=
splitScreenMode
?
max
(
constraints
.
maxHeight
,
700
)
:
constraints
.
maxHeight
;
..
_screenHeight
=
splitScreenMode
?
max
(
constraints
.
maxHeight
,
700
)
:
constraints
.
maxHeight
;
var
window
=
WidgetsBinding
.
instance
?.
window
??
ui
.
window
;
_instance
.
_pixelRatio
=
window
.
devicePixelRatio
;
...
...
@@ -84,7 +85,7 @@ class ScreenUtil {
/// /// The ratio of actual height to UI design
double
get
scaleHeight
=>
_screenHeight
/
uiSize
.
height
;
double
get
scaleText
=>
scaleWidth
;
double
get
scaleText
=>
_minTextAdapt
?
min
(
scaleWidth
,
scaleHeight
)
:
scaleWidth
;
/// 根据UI设计的设备宽度适配
/// 高度也可以根据这个来做适配可以保证不变形,比如你想要一个正方形的时候.
...
...
lib/screenutil_init.dart
View file @
e35ffdd
...
...
@@ -6,11 +6,13 @@ class ScreenUtilInit extends StatelessWidget {
required
this
.
builder
,
this
.
designSize
=
ScreenUtil
.
defaultSize
,
this
.
splitScreenMode
=
true
,
this
.
minTextAdapt
=
false
,
Key
?
key
,
})
:
super
(
key:
key
);
final
Widget
Function
()
builder
;
final
bool
splitScreenMode
;
final
bool
minTextAdapt
;
/// The [Size] of the device in the design draft, in dp
final
Size
designSize
;
...
...
@@ -19,14 +21,14 @@ class ScreenUtilInit extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
return
LayoutBuilder
(
builder:
(
_
,
BoxConstraints
constraints
)
{
if
(
constraints
.
maxWidth
!=
0
)
{
final
Orientation
orientation
=
constraints
.
maxWidth
>
constraints
.
maxHeight
?
Orientation
.
landscape
:
Orientation
.
portrait
;
final
Orientation
orientation
=
constraints
.
maxWidth
>
constraints
.
maxHeight
?
Orientation
.
landscape
:
Orientation
.
portrait
;
ScreenUtil
.
init
(
constraints
,
orientation:
orientation
,
designSize:
designSize
,
splitScreenMode:
splitScreenMode
);
splitScreenMode:
splitScreenMode
,
minTextAdapt:
minTextAdapt
);
return
builder
();
}
return
Container
();
...
...
pubspec.yaml
View file @
e35ffdd
name
:
flutter_screenutil
description
:
A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
version
:
5.0.
1+
2
version
:
5.0.2
homepage
:
https://github.com/OpenFlutter/flutter_screenutil
environment
:
...
...
Please
register
or
login
to post a comment