Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
__卓原
flutter_screenutil
提交
3ec74132
F
flutter_screenutil
项目概览
__卓原
/
flutter_screenutil
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flutter_screenutil
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3ec74132
编写于
5月 15, 2019
作者:
李
李卓原
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化部分示例
上级
a16e14eb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
57 addition
and
56 deletion
+57
-56
.packages
.packages
+9
-8
example/lib/main.dart
example/lib/main.dart
+7
-12
example/lib/main_zh.dart
example/lib/main_zh.dart
+19
-21
example/pubspec.lock
example/pubspec.lock
+7
-7
pubspec.lock
pubspec.lock
+15
-8
未找到文件。
.packages
浏览文件 @
3ec74132
# Generated by pub on 2019-0
2-21 16:04:26.823126
.
async:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.
0.8
/lib/
# Generated by pub on 2019-0
5-15 14:31:19.119581
.
async:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.
1.0
/lib/
boolean_selector:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib/
charcode:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
collection:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
flutter:file:///D:/flutter/packages/flutter/lib/
flutter_test:file:///D:/flutter/packages/flutter_test/lib/
matcher:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.
3+1
/lib/
matcher:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.
5
/lib/
meta:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/
path:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib/
quiver:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.1/lib/
pedantic:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.5.0/lib/
quiver:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.2/lib/
sky_engine:file:///D:/flutter/bin/cache/pkg/sky_engine/lib/
source_span:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.
4.1
/lib/
source_span:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.
5.5
/lib/
stack_trace:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/
stream_channel:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-
1.6.8
/lib/
stream_channel:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-
2.0.0
/lib/
string_scanner:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib/
term_glyph:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.
0.1
/lib/
test_api:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.
1
/lib/
term_glyph:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.
1.0
/lib/
test_api:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.
4
/lib/
typed_data:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
vector_math:file:///D:/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
flutter_screenutil:lib/
example/lib/main.dart
浏览文件 @
3ec74132
...
...
@@ -33,14 +33,14 @@ class _MyHomePageState extends State<MyHomePage> {
///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)
ScreenUtil
.
instance
=
ScreenUtil
(
width:
750
,
height:
1334
)..
init
(
context
);
print
(
'Device width:
${ScreenUtil.screenWidth}
'
);
//Device width
print
(
'Device height:
${ScreenUtil.screenHeight}
'
);
//Device height
print
(
'Device width
px
:
${ScreenUtil.screenWidth}
'
);
//Device width
print
(
'Device height
px
:
${ScreenUtil.screenHeight}
'
);
//Device height
print
(
'Device pixel density:
${ScreenUtil.pixelRatio}
'
);
//Device pixel density
print
(
'Bottom safe zone distance:
${ScreenUtil.bottomBarHeight}
'
);
//Bottom safe zone distance,suitable for buttons with full screen
'Bottom safe zone distance
px
:
${ScreenUtil.bottomBarHeight}
'
);
//Bottom safe zone distance,suitable for buttons with full screen
print
(
'Status bar height:
${ScreenUtil.statusBarHeight}
px'
);
//Status bar height , Notch will be higher Unit px
'Status bar height
px
:
${ScreenUtil.statusBarHeight}
px'
);
//Status bar height , Notch will be higher Unit px
print
(
'Ratio of actual width dp to design draft px:
${ScreenUtil.getInstance().scaleWidth}
'
);
print
(
...
...
@@ -49,6 +49,7 @@ class _MyHomePageState extends State<MyHomePage> {
'The ratio of font and width to the size of the design:
${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}
'
);
print
(
'The ratio of height width to the size of the design:
${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}
'
);
return
new
Scaffold
(
appBar:
new
AppBar
(
title:
new
Text
(
widget
.
title
),
...
...
@@ -84,6 +85,8 @@ class _MyHomePageState extends State<MyHomePage> {
),
Text
(
'Device width:
${ScreenUtil.screenWidth}
px'
),
Text
(
'Device height:
${ScreenUtil.screenHeight}
px'
),
Text
(
'Device width:
${ScreenUtil.screenWidthDp}
dp'
),
Text
(
'Device height:
${ScreenUtil.screenHeightDp}
dp'
),
Text
(
'Device pixel density:
${ScreenUtil.pixelRatio}
'
),
Text
(
'Bottom safe zone distance:
${ScreenUtil.bottomBarHeight}
px'
),
Text
(
'Status bar height:
${ScreenUtil.statusBarHeight}
px'
),
...
...
@@ -95,14 +98,6 @@ class _MyHomePageState extends State<MyHomePage> {
'Ratio of actual height dp to design draft px:
${ScreenUtil.getInstance().scaleHeight}
'
,
textAlign:
TextAlign
.
center
,
),
Text
(
'The ratio of font and width to the size of the design:
${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}
'
,
textAlign:
TextAlign
.
center
,
),
Text
(
'The ratio of height width to the size of the design:
${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}
'
,
textAlign:
TextAlign
.
center
,
),
SizedBox
(
height:
ScreenUtil
.
getInstance
().
setHeight
(
100
),
),
...
...
example/lib/main_zh.dart
浏览文件 @
3ec74132
...
...
@@ -45,12 +45,13 @@ class _MyHomePageState extends State<MyHomePage> {
print
(
'宽度和字体相对于设计稿放大的比例:
${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}
'
);
print
(
'高度相对于设计稿放大的比例:
${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}
'
);
print
(
'高度相对于设计稿放大的比例:
${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}
'
);
print
(
'系统的字体缩放比例:
${ScreenUtil.textScaleFactory}
'
);
return
new
Scaffold
(
appBar:
new
AppBar
(
title:
new
Text
(
widget
.
title
),
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
widget
.
title
),
),
floatingActionButton:
FloatingActionButton
(
onPressed:
()
{
...
...
@@ -82,35 +83,31 @@ class _MyHomePageState extends State<MyHomePage> {
width:
ScreenUtil
.
getInstance
().
setWidth
(
375
),
height:
ScreenUtil
.
getInstance
().
setHeight
(
200
),
color:
Colors
.
blue
,
child:
Text
(
'我的宽度:
${ScreenUtil.getInstance().setWidth(375)}
dp'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
ScreenUtil
.
getInstance
().
setSp
(
24
),
)),
child:
Text
(
'我的宽度:
${ScreenUtil.getInstance().setWidth(375)}
dp'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
ScreenUtil
.
getInstance
().
setSp
(
24
),
)),
),
],
),
Text
(
'设备宽度:
${ScreenUtil.screenWidth}
px'
),
Text
(
'设备高度:
${ScreenUtil.screenHeight}
px'
),
Text
(
'设备宽度:
${ScreenUtil.screenWidthDp}
dp'
),
Text
(
'设备高度:
${ScreenUtil.screenHeightDp}
dp'
),
Text
(
'设计稿宽度:
${ScreenUtil.getInstance().width}
'
),
Text
(
'设备的像素密度:
${ScreenUtil.pixelRatio}
'
),
Text
(
'底部安全区距离:
${ScreenUtil.bottomBarHeight}
px'
),
Text
(
'状态栏高度:
${ScreenUtil.statusBarHeight}
px'
),
Text
(
'实际
高度的dp与设计稿px的比例:
${ScreenUtil.getInstance().scaleHeight
}
'
,
'实际
宽度的dp与设计稿px的比例:
${ScreenUtil.getInstance().scaleWidth
}
'
,
textAlign:
TextAlign
.
center
,
),
Text
(
'实际高度的dp与设计稿px的比例:
${ScreenUtil.getInstance().scaleHeight}
'
,
textAlign:
TextAlign
.
center
,
),
Text
(
'宽度和字体相对于设计稿放大的比例:
${ScreenUtil.getInstance().scaleWidth * ScreenUtil.pixelRatio}
'
,
textAlign:
TextAlign
.
center
,
),
Text
(
'高度相对于设计稿放大的比例:
${ScreenUtil.getInstance().scaleHeight * ScreenUtil.pixelRatio}
'
,
textAlign:
TextAlign
.
center
,
),
SizedBox
(
height:
ScreenUtil
.
getInstance
().
setHeight
(
100
),
),
...
...
@@ -118,10 +115,11 @@ class _MyHomePageState extends State<MyHomePage> {
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Text
(
'我的文字大小在设计稿上是2
5
px,不会随着系统的文字缩放比例变化'
,
Text
(
'我的文字大小在设计稿上是2
4
px,不会随着系统的文字缩放比例变化'
,
style:
TextStyle
(
color:
Colors
.
black
,
fontSize:
ScreenUtil
.
getInstance
().
setSp
(
24
))),
Text
(
'我的文字大小在设计稿上是25px,会随着系统的文字缩放比例变化'
,
color:
Colors
.
black
,
fontSize:
ScreenUtil
.
getInstance
().
setSp
(
24
))),
Text
(
'我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化'
,
style:
TextStyle
(
color:
Colors
.
black
,
fontSize:
...
...
example/pubspec.lock
浏览文件 @
3ec74132
...
...
@@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.
0.8
"
version: "2.
1.0
"
boolean_selector:
dependency: transitive
description:
...
...
@@ -47,7 +47,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.5.
1
"
version: "0.5.
2
"
flutter_test:
dependency: "direct dev"
description: flutter
...
...
@@ -59,7 +59,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.
3+1
"
version: "0.12.
5
"
meta:
dependency: transitive
description:
...
...
@@ -87,7 +87,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.
1
"
version: "2.0.
2
"
sky_engine:
dependency: transitive
description: flutter
...
...
@@ -113,7 +113,7 @@ packages:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "
1.6.8
"
version: "
2.0.0
"
string_scanner:
dependency: transitive
description:
...
...
@@ -134,7 +134,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.
2
"
version: "0.2.
4
"
typed_data:
dependency: transitive
description:
...
...
@@ -150,4 +150,4 @@ packages:
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.
1.1-dev.0
.0 <3.0.0"
dart: ">=2.
2
.0 <3.0.0"
pubspec.lock
浏览文件 @
3ec74132
...
...
@@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.
0.8
"
version: "2.
1.0
"
boolean_selector:
dependency: transitive
description:
...
...
@@ -45,7 +45,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.
3+1
"
version: "0.12.
5
"
meta:
dependency: transitive
description:
...
...
@@ -60,13 +60,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.
1
"
version: "2.0.
2
"
sky_engine:
dependency: transitive
description: flutter
...
...
@@ -78,7 +85,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.
4.1
"
version: "1.
5.5
"
stack_trace:
dependency: transitive
description:
...
...
@@ -92,7 +99,7 @@ packages:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "
1.6.8
"
version: "
2.0.0
"
string_scanner:
dependency: transitive
description:
...
...
@@ -106,14 +113,14 @@ packages:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.
0.1
"
version: "1.
1.0
"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.
1
"
version: "0.2.
4
"
typed_data:
dependency: transitive
description:
...
...
@@ -129,4 +136,4 @@ packages:
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.
0
.0 <3.0.0"
dart: ">=2.
2
.0 <3.0.0"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录