Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
李卓原 committed Oct 15, 2020
2 parents 115e489 + 5240c03 commit faa60f9
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 133 deletions.
4 changes: 4 additions & 0 deletions .flutter_tool_state
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"is-bot": true,
"redisplay-welcome-message": false
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
* @LastEditTime: 2020年6月20日 11:20:02
* @Description: Update log
-->

# 3.1.1
- change readme

# 3.1.0
- Use the way back to v2 version
- Modify registration method

# 3.0.2+1
- Guide users to use V2 version

# 3.0.2
- Change the unit of'statusBarHeight' and 'bottomBarHeight' to dp

Expand Down
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

[Update log](https://github.com/OpenFlutter/flutter_screenutil/blob/master/CHANGELOG.md)

## Note
[v3](https://github.com/OpenFlutter/flutter_screenutil/tree/beta) requires `flutter >= 1.19.0`.

[v2](https://github.com/OpenFlutter/flutter_screenutil) support all versions.

## Usage:

### Add dependency:
Expand All @@ -28,7 +23,7 @@ dependencies:
flutter:
sdk: flutter
# add flutter_screenutil
flutter_screenutil: ^3.0.2
flutter_screenutil: ^3.1.0
```
### Add the following imports to your Dart code:
```
Expand All @@ -50,20 +45,20 @@ Please set the size of the design draft before use, the width and height of the
void main() {
WidgetsFlutterBinding.ensureInitialized();
//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.init(designSize: Size(750, 1334), allowFontScaling: false);
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
runApp(MyApp());
}
//fill in the screen size of the device in the design
//default value : width : 1080px , height:1920px , allowFontScaling:false
ScreenUtil.init();
ScreenUtil.init(context);
//If the design is based on the size of the iPhone6 ​​(iPhone6 ​​750*1334)
ScreenUtil.init(designSize: Size(750, 1334));
ScreenUtil.init(context, designSize: Size(750, 1334));
//If you want to set the font size is scaled according to the system's "font size" assist option
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: true);
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
```

Expand Down
56 changes: 31 additions & 25 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@

[更新日志](https://github.com/OpenFlutter/flutter_screenutil/blob/master/CHANGELOG.md)

## Note
[v3](https://github.com/OpenFlutter/flutter_screenutil/tree/beta)可用于`flutter >= 1.19.0`

[v2](https://github.com/OpenFlutter/flutter_screenutil)可用于所有版本。

## 使用方法:

### 安装依赖:
Expand All @@ -33,7 +28,7 @@ dependencies:
flutter:
sdk: flutter
# 添加依赖
flutter_screenutil: ^3.0.2
flutter_screenutil: ^3.1.0
```
### 在每个使用的地方导入包:
```
Expand All @@ -57,18 +52,18 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: false);
ScreenUtil.init(context,designSize: Size(750, 1334), allowFontScaling: false);
runApp(MyApp());
}
//默认 width : 1080px , height:1920px , allowFontScaling:false
ScreenUtil.init();
ScreenUtil.init(context);
//假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
ScreenUtil.init(designSize: Size(750, 1334));
ScreenUtil.init(context, designSize: Size(750, 1334));
//设置字体大小根据系统的“字体大小”辅助选项来进行缩放,默认为false
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: true);
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
```

Expand Down Expand Up @@ -180,12 +175,10 @@ Column(
```

```dart
void main() {
WidgetsFlutterBinding.ensureInitialized();
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: false);
runApp(MyApp());
}
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Expand All @@ -196,11 +189,20 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: ExampleWidget(title: 'FlutterScreenUtil示例'),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
return ExampleWidget(title: 'FlutterScreenUtil 示例');
}
}
class ExampleWidget extends StatefulWidget {
const ExampleWidget({Key key, this.title}) : super(key: key);
Expand Down Expand Up @@ -232,8 +234,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
child: Text(
'我的宽度:${0.5.wp}dp \n'
'我的高度:${ScreenUtil().setHeight(200)}dp',
style: TextStyle(
color: Colors.white, fontSize: ScreenUtil().setSp(24)),
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24)),
),
),
Container(
Expand All @@ -244,9 +245,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
child: Text(
'我的宽度:${375.w}dp \n'
'我的高度:${200.h}dp',
style: TextStyle(
color: Colors.white,
fontSize: ScreenUtil().setSp(24))),
style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(24))),
),
],
),
Expand Down Expand Up @@ -274,11 +273,17 @@ class _ExampleWidgetState extends State<ExampleWidget> {
children: <Widget>[
Text(
'我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化',
style: ts.t2,
style: TextStyle(
color: Colors.black,
fontSize: 24.sp,
),
),
Text(
'我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化',
style: ts.t1,
style: TextStyle(
color: Colors.black,
fontSize: 24.ssp,
),
),
],
)
Expand All @@ -289,7 +294,8 @@ class _ExampleWidgetState extends State<ExampleWidget> {
child: Icon(Icons.title),
onPressed: () {
ScreenUtil.init(
designSize: Size(1500, 1334),
context,
designSize: Size(750, 1334),
allowFontScaling: false,
);
setState(() {});
Expand Down
15 changes: 5 additions & 10 deletions README_PT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

[Histórico de atualizações](https://github.com/OpenFlutter/flutter_screenutil/blob/master/CHANGELOG.md)

## Note
[v3](https://github.com/OpenFlutter/flutter_screenutil/tree/beta) requer `flutter >= 1.19.0`.

[v2](https://github.com/OpenFlutter/flutter_screenutil) support all versions.

## Como usar:

### Adicionando a dependência:
Expand All @@ -28,7 +23,7 @@ dependencies:
flutter:
sdk: flutter
# add flutter_screenutil
flutter_screenutil: ^3.0.2
flutter_screenutil: ^3.1.0
```

### Adicione o seguinte import em seu código Dart:
Expand All @@ -53,18 +48,18 @@ Certifique-se de definir as dimensões na paginal inicial do MaterialApp (ou sej
void main() {
WidgetsFlutterBinding.ensureInitialized();
//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.init(designSize: Size(750, 1334), allowFontScaling: false);
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
runApp(MyApp());
}
//Valor padrão: width : 1080px , height:1920px , allowFontScaling:false
ScreenUtil.init();
ScreenUtil.init(context);
//Se o design é baseado no iPhone6 ​​(iPhone6 ​​750*1334)
ScreenUtil.init(designSize: Size(750, 1334));
ScreenUtil.init(context, designSize: Size(750, 1334));
//Se você quer definir que o tamanho da fonte seja ajustado de acordo com a opção "tamanho da fonte" na acessibilidade do sistema
ScreenUtil.init(designSize: Size(750, 1334), allowFontScaling: true);
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true);
```

Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="example"
android:label="flutter_screenutil"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
44 changes: 23 additions & 21 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'text_style.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
//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.init(designSize: Size(750, 1334), allowFontScaling: false);
runApp(MyApp());
}
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Expand All @@ -21,11 +14,20 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: ExampleWidget(title: 'FlutterScreenUtil Demo'),
home: MyHomePage(),
);
}
}

class MyHomePage 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 ​​(iPhone6 ​​750*1334)
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
return ExampleWidget(title: 'FlutterScreenUtil Demo');
}
}

class ExampleWidget extends StatefulWidget {
const ExampleWidget({Key key, this.title}) : super(key: key);

Expand All @@ -38,7 +40,10 @@ class ExampleWidget extends StatefulWidget {
class _ExampleWidgetState extends State<ExampleWidget> {
@override
Widget build(BuildContext context) {
// printScreenInformation();
//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.init(context, designSize: Size(750, 1334), allowFontScaling: false);

printScreenInformation();
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
Expand Down Expand Up @@ -112,7 +117,10 @@ class _ExampleWidgetState extends State<ExampleWidget> {
),
Text(
'My font size is 24px on the design draft and will change with the system.',
style: ts.t1,
style: TextStyle(
color: Colors.black,
fontSize: 24.ssp,
),
),
],
)
Expand All @@ -122,10 +130,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
floatingActionButton: FloatingActionButton(
child: Icon(Icons.title),
onPressed: () {
ScreenUtil.init(
designSize: Size(750, 1334),
allowFontScaling: false,
);
ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: false);
setState(() {});
},
),
Expand All @@ -135,16 +140,13 @@ class _ExampleWidgetState extends State<ExampleWidget> {
void printScreenInformation() {
print('Device width dp:${ScreenUtil().screenWidth}'); //Device width
print('Device height dp:${ScreenUtil().screenHeight}'); //Device height
print(
'Device pixel density:${ScreenUtil().pixelRatio}'); //Device pixel density
print('Device pixel density:${ScreenUtil().pixelRatio}'); //Device pixel density
print(
'Bottom safe zone distance dp:${ScreenUtil().bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen
print(
'Status bar height px:${ScreenUtil().statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px
print(
'Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth}');
print(
'Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight}');
print('Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth}');
print('Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight}');
print(
'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth * ScreenUtil().pixelRatio}');
print(
Expand Down
Loading

0 comments on commit faa60f9

Please sign in to comment.