Showing
6 changed files
with
14 additions
and
9 deletions
| @@ -23,7 +23,7 @@ dependencies: | @@ -23,7 +23,7 @@ dependencies: | ||
| 23 | flutter: | 23 | flutter: |
| 24 | sdk: flutter | 24 | sdk: flutter |
| 25 | # add flutter_screenutil | 25 | # add flutter_screenutil |
| 26 | - flutter_screenutil: ^5.0.0-nullsafety.1 | 26 | + flutter_screenutil: ^{latest version} |
| 27 | ``` | 27 | ``` |
| 28 | ### Add the following imports to your Dart code: | 28 | ### Add the following imports to your Dart code: |
| 29 | ```dart | 29 | ```dart |
| @@ -28,7 +28,7 @@ dependencies: | @@ -28,7 +28,7 @@ dependencies: | ||
| 28 | flutter: | 28 | flutter: |
| 29 | sdk: flutter | 29 | sdk: flutter |
| 30 | # 添加依赖 | 30 | # 添加依赖 |
| 31 | - flutter_screenutil: ^5.0.0-nullsafety.1 | 31 | + flutter_screenutil: ^{latest version} |
| 32 | ``` | 32 | ``` |
| 33 | ### 在每个使用的地方导入包: | 33 | ### 在每个使用的地方导入包: |
| 34 | ```dart | 34 | ```dart |
| @@ -24,7 +24,7 @@ dependencies: | @@ -24,7 +24,7 @@ dependencies: | ||
| 24 | flutter: | 24 | flutter: |
| 25 | sdk: flutter | 25 | sdk: flutter |
| 26 | # add flutter_screenutil | 26 | # add flutter_screenutil |
| 27 | - flutter_screenutil: ^5.0.0-nullsafety.1 | 27 | + flutter_screenutil: ^{latest version} |
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | ### Adicione o seguinte import em seu código Dart: | 30 | ### Adicione o seguinte import em seu código Dart: |
| @@ -22,12 +22,14 @@ class ScreenUtilInit extends StatelessWidget { | @@ -22,12 +22,14 @@ class ScreenUtilInit extends StatelessWidget { | ||
| 22 | @override | 22 | @override |
| 23 | Widget build(BuildContext context) { | 23 | Widget build(BuildContext context) { |
| 24 | return LayoutBuilder( | 24 | return LayoutBuilder( |
| 25 | + // ignore: missing_return | ||
| 25 | builder: (_, BoxConstraints constraints) { | 26 | builder: (_, BoxConstraints constraints) { |
| 26 | - ScreenUtil.init( | ||
| 27 | - constraints, | ||
| 28 | - designSize: designSize, | ||
| 29 | - allowFontScaling: allowFontScaling, | ||
| 30 | - ); | 27 | + if (constraints.maxWidth != 0) { |
| 28 | + ScreenUtil.init( | ||
| 29 | + constraints, | ||
| 30 | + designSize: designSize, | ||
| 31 | + allowFontScaling: allowFontScaling, | ||
| 32 | + ); | ||
| 31 | 33 | ||
| 32 | return child; | 34 | return child; |
| 33 | }, | 35 | }, |
| 1 | name: flutter_screenutil | 1 | name: flutter_screenutil |
| 2 | description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models | 2 | description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models |
| 3 | -version: 5.0.0-nullsafety.2 | 3 | +version: 5.0.0-nullsafety.3 |
| 4 | homepage: https://github.com/OpenFlutter/flutter_screenutil | 4 | homepage: https://github.com/OpenFlutter/flutter_screenutil |
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
-
Please register or login to post a comment