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
LiZhuoyuan
2021-02-21 10:41:22 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Committed by
GitHub
2021-02-21 10:41:22 +0800
Commit
ae9af6d574dc3cfcdf23d561be19a769753a30b5
ae9af6d5
2 parents
e53982f1
9b5bb336
Merge pull request #218 from ytx222/patch-2
修改为新版的初始化
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
README_CN.md
README_CN.md
View file @
ae9af6d
...
...
@@ -49,18 +49,24 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
```
dart
//填入设计稿中设备的屏幕尺寸
void
main
(
)
=>
runApp
(
MyApp
());
class
HomePage
extends
StatelessWidget
{
const
HomePage
({
Key
key
})
:
super
(
key:
key
);
class
MyApp
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸,单位dp)
return
ScreenUtilInit
(
designSize:
Size
(
360
,
690
),
allowFontScaling:
false
,
builder:
()
=>
MaterialApp
(
...
// 初始化
ScreenUtil
.
init
(
// 设备像素大小(必须在首页中获取)
BoxConstraints
(
maxWidth:
MediaQuery
.
of
(
context
).
size
.
width
,
maxHeight:
MediaQuery
.
of
(
context
).
size
.
height
,
),
// 设计尺寸
designSize:
Size
(
750
,
1334
),
allowFontScaling:
false
,
);
return
Container
(
child:
child
,
);
}
}
...
...
Please
register
or
login
to post a comment