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
李卓原
2022-01-04 16:32:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f7a0f7cb4be5754fa5a2b3b0650a6b5e300cf36f
f7a0f7cb
1 parent
ad87543f
5.0.3
#241
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
53 additions
and
21 deletions
CHANGELOG.md
README.md
README_CN.md
README_PT.md
example/ios/Flutter/flutter_export_environment.sh
example/lib/main.dart
example/lib/main_zh.dart
lib/screen_util.dart
lib/screenutil_init.dart
pubspec.yaml
CHANGELOG.md
View file @
f7a0f7c
# 5.0.3
-
init method add "context" param
-
update ReadMe.md
# 5.0.2+1
-
fix splitScreenMode to false
# 5.0.2
-
add "minTextAdapt" param , Font adaptation is based on the minimum value of width and height or only based on width(default)
-
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
...
...
README.md
View file @
f7a0f7c
...
...
@@ -70,6 +70,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
<td>
false
</td>
<td>
Whether to adapt the text according to the minimum of width and height
</td>
</tr>
<tr>
<td>
context
</td>
<td>
BuildContext
</td>
<td>
null
</td>
<td>
If context!=null, screen changes will be more sensitive
</td>
</tr>
</table>
### Initialize and set the fit size and font size to scale according to the system's "font size" accessibility option
...
...
README_CN.md
View file @
f7a0f7c
...
...
@@ -45,7 +45,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|builder|Widget Function()|Container()|一般返回一个MaterialApp类型的Function()|
|orientation|Orientation|portrait|屏幕方向|
|splitScreenMode|bool|true|支持分屏尺寸|
|minTextAdapt|bool|false|Whether to adapt the text according to the minimum of width and height|
|minTextAdapt|bool|false|是否根据宽度/高度中的最小值适配文字|
|context|BuildContext|null|传入context会更灵敏的根据屏幕变化而改变|
### 初始化并设置适配尺寸及字体大小是否根据系统的“字体大小”辅助选项来进行缩放
在使用之前请设置好设计稿的宽度和高度,传入设计稿的宽度和高度(单位随意,但在使用过程中必须保持一致)
...
...
README_PT.md
View file @
f7a0f7c
...
...
@@ -42,6 +42,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|builder|Widget Function()|Container()|Generally returning a Function of MaterialApp type|
|orientation|Orientation|portrait|screen orientation|
|minTextAdapt|bool|false|Whether to adapt the text according to the minimum of width and height|
|context|BuildContext|null|传入context会更灵敏的根据屏幕变化而改变|
### Inicialize e defina o tamanho de ajuste e tamanho da fonte para dimensionar de acordo com a opção "tamanho de fonte" na acessibilidade do sistema
Por favor, defina a largura e altura do protótipo de design antes de usar (em pixels).
...
...
example/ios/Flutter/flutter_export_environment.sh
View file @
f7a0f7c
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export
"FLUTTER_ROOT=C:
\f
lutter"
export
"FLUTTER_APPLICATION_PATH=C:
\U
sers
\A
vnish
\D
ownloads
\f
lutter_screenutil
\e
xample"
export
"FLUTTER_ROOT=/Users/lizhuoyuan/Development/flutter"
export
"FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example"
export
"COCOAPODS_PARALLEL_CODE_SIGN=true"
export
"FLUTTER_TARGET=lib
\
m
ain.dart"
export
"FLUTTER_TARGET=lib
/
main.dart"
export
"FLUTTER_BUILD_DIR=build"
export
"FLUTTER_BUILD_NAME=1.0.0"
export
"FLUTTER_BUILD_NUMBER=1"
...
...
example/lib/main.dart
View file @
f7a0f7c
import
'package:flutter/material.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
void
main
(
)
=>
runApp
(
MyApp
());
void
main
(
)
{
WidgetsFlutterBinding
.
ensureInitialized
();
runApp
(
MyApp
());
}
class
MyApp
extends
StatelessWidget
{
@override
...
...
@@ -87,7 +90,7 @@ class _HomePageState extends State<HomePage> {
],
),
Container
(
padding:
EdgeInsets
.
all
(
ScreenUtil
().
setWidth
(
10
)
),
padding:
EdgeInsets
.
all
(
10
.
w
),
width:
100
.
r
,
height:
100
.
r
,
color:
Colors
.
green
,
...
...
@@ -95,11 +98,10 @@ class _HomePageState extends State<HomePage> {
'I am a square with a side length of 100'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
ScreenUtil
().
setSp
(
12
)
,
fontSize:
12
.
sp
,
),
),
),
TextField
(
style:
TextStyle
(
fontSize:
180
.
sp
)),
Text
(
'Device width:
${ScreenUtil().screenWidth}
dp'
),
Text
(
'Device height:
${ScreenUtil().screenHeight}
dp'
),
Text
(
'Device pixel density:
${ScreenUtil().pixelRatio}
'
),
...
...
example/lib/main_zh.dart
View file @
f7a0f7c
...
...
@@ -37,6 +37,7 @@ class _HomePageState extends State<HomePage> {
maxWidth:
MediaQuery
.
of
(
context
).
size
.
width
,
maxHeight:
MediaQuery
.
of
(
context
).
size
.
height
),
designSize:
Size
(
360
,
690
),
context:
context
,
);
printScreenInformation
();
return
Scaffold
(
...
...
lib/screen_util.dart
View file @
f7a0f7c
...
...
@@ -31,6 +31,7 @@ class ScreenUtil {
static
void
init
(
BoxConstraints
constraints
,
{
BuildContext
?
context
,
Orientation
orientation
=
Orientation
.
portrait
,
Size
designSize
=
defaultSize
,
bool
splitScreenMode
=
false
,
...
...
@@ -41,13 +42,20 @@ class ScreenUtil {
..
_minTextAdapt
=
minTextAdapt
..
_orientation
=
orientation
..
_screenWidth
=
constraints
.
maxWidth
..
_screenHeight
=
splitScreenMode
?
max
(
constraints
.
maxHeight
,
700
)
:
constraints
.
maxHeight
;
var
window
=
WidgetsBinding
.
instance
?.
window
??
ui
.
window
;
_instance
.
_pixelRatio
=
window
.
devicePixelRatio
;
_instance
.
_statusBarHeight
=
window
.
padding
.
top
;
_instance
.
_bottomBarHeight
=
window
.
padding
.
bottom
;
_instance
.
_textScaleFactor
=
window
.
textScaleFactor
;
..
_screenHeight
=
splitScreenMode
?
max
(
constraints
.
maxHeight
,
700
)
:
constraints
.
maxHeight
;
var
windowData
;
if
(
context
!=
null
)
{
windowData
=
MediaQuery
.
of
(
context
);
}
else
{
windowData
=
WidgetsBinding
.
instance
?.
window
??
ui
.
window
;
}
_instance
.
_pixelRatio
=
windowData
.
devicePixelRatio
;
_instance
.
_statusBarHeight
=
windowData
.
padding
.
top
;
_instance
.
_bottomBarHeight
=
windowData
.
padding
.
bottom
;
_instance
.
_textScaleFactor
=
windowData
.
textScaleFactor
;
}
///获取屏幕方向
...
...
@@ -85,7 +93,8 @@ class ScreenUtil {
/// /// The ratio of actual height to UI design
double
get
scaleHeight
=>
_screenHeight
/
uiSize
.
height
;
double
get
scaleText
=>
_minTextAdapt
?
min
(
scaleWidth
,
scaleHeight
)
:
scaleWidth
;
double
get
scaleText
=>
_minTextAdapt
?
min
(
scaleWidth
,
scaleHeight
)
:
scaleWidth
;
/// 根据UI设计的设备宽度适配
/// 高度也可以根据这个来做适配可以保证不变形,比如你想要一个正方形的时候.
...
...
lib/screenutil_init.dart
View file @
f7a0f7c
...
...
@@ -19,12 +19,16 @@ class ScreenUtilInit extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
LayoutBuilder
(
builder:
(
_
,
BoxConstraints
constraints
)
{
return
MediaQuery
(
data:
MediaQueryData
(),
child:
LayoutBuilder
(
builder:
(
_
,
BoxConstraints
constraints
)
{
if
(
constraints
.
maxWidth
!=
0
)
{
final
Orientation
orientation
=
constraints
.
maxWidth
>
constraints
.
maxHeight
final
Orientation
orientation
=
constraints
.
maxWidth
>
constraints
.
maxHeight
?
Orientation
.
landscape
:
Orientation
.
portrait
;
ScreenUtil
.
init
(
constraints
,
context:
_
,
orientation:
orientation
,
designSize:
designSize
,
splitScreenMode:
splitScreenMode
,
...
...
@@ -32,6 +36,7 @@ class ScreenUtilInit extends StatelessWidget {
return
builder
();
}
return
Container
();
});
}),
);
}
}
...
...
pubspec.yaml
View file @
f7a0f7c
name
:
flutter_screenutil
description
:
A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
version
:
5.0.
2+1
version
:
5.0.
3
homepage
:
https://github.com/OpenFlutter/flutter_screenutil
environment
:
...
...
Please
register
or
login
to post a comment