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
李卓原
2021-03-11 14:34:00 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0542853d18db41dc14fc8235492ddcdfb627566a
0542853d
1 parent
f29a8517
# 5.0.0-nullsafety.9
添加新的初始化方式
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
87 additions
and
12 deletions
CHANGELOG.md
README.md
README_CN.md
README_PT.md
example/lib/main_zh.dart
pubspec.yaml
CHANGELOG.md
View file @
0542853
# 5.0.0-nullsafety.9
-
Supplementary documentation, supports two initialization methods
# 5.0.0-nullsafety.8
-
merge v4
-
Add a method to get the screen orientation
...
...
README.md
View file @
0542853
...
...
@@ -58,13 +58,11 @@ class MyApp extends StatelessWidget {
}
}
```
The second way:
The second way:
Does not support the use of font adaptation in the App
```
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
//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 360*690
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter_ScreenUtil',
...
...
@@ -75,6 +73,30 @@ class MyApp extends StatelessWidget {
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
//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 360*690(dp)
ScreenUtil.init(
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
allowFontScaling: false,
orientation: Orientation.portrait);
return Scaffold();
}
}
```
### Use:
...
...
README_CN.md
View file @
0542853
...
...
@@ -69,13 +69,11 @@ class MyApp extends StatelessWidget {
}
}
```
方式二:
方式二:
不支持在App中使用字体适配
```
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
//填入设计稿中设备的屏幕尺寸 (例如:360*690) , 单位dp
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter_ScreenUtil',
...
...
@@ -86,6 +84,30 @@ class MyApp extends StatelessWidget {
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
//设置尺寸(填写设计中设备的屏幕尺寸)如果设计基于360dp * 690dp的屏幕
ScreenUtil.init(
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
allowFontScaling: false,
orientation: Orientation.portrait);
return Scaffold();
}
}
```
### 使用
...
...
README_PT.md
View file @
0542853
...
...
@@ -62,13 +62,11 @@ class MyApp extends StatelessWidget {
}
}
```
The second way:
The second way:
Does not support the use of font adaptation in the App
```
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
//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 360*690
ScreenUtil.init(BoxConstraints(maxWidth: 360, maxHeight: 690));
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter_ScreenUtil',
...
...
@@ -79,6 +77,30 @@ class MyApp extends StatelessWidget {
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
//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 360*690(dp)
ScreenUtil.init(
BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
allowFontScaling: false,
orientation: Orientation.portrait);
return Scaffold();
}
}
```
### Uso:
...
...
example/lib/main_zh.dart
View file @
0542853
...
...
@@ -6,8 +6,6 @@ void main() => runApp(MyApp());
class
MyApp
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
//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 360*690
ScreenUtil
.
init
(
BoxConstraints
(
maxWidth:
360
,
maxHeight:
690
));
return
MaterialApp
(
debugShowCheckedModeBanner:
false
,
title:
'Flutter_ScreenUtil'
,
...
...
@@ -31,6 +29,14 @@ class HomePage extends StatefulWidget {
class
_HomePageState
extends
State
<
HomePage
>
{
@override
Widget
build
(
BuildContext
context
)
{
//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 360*690
ScreenUtil
.
init
(
BoxConstraints
(
maxWidth:
MediaQuery
.
of
(
context
).
size
.
width
,
maxHeight:
MediaQuery
.
of
(
context
).
size
.
height
),
designSize:
Size
(
360
,
690
),
allowFontScaling:
false
,
orientation:
Orientation
.
portrait
);
printScreenInformation
();
return
Scaffold
(
appBar:
AppBar
(
...
...
pubspec.yaml
View file @
0542853
name
:
flutter_screenutil
description
:
A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
version
:
5.0.0-nullsafety.
8
version
:
5.0.0-nullsafety.
9
homepage
:
https://github.com/OpenFlutter/flutter_screenutil
environment
:
...
...
Please
register
or
login
to post a comment