Showing
5 changed files
with
22 additions
and
71 deletions
| 1 | -<!-- | ||
| 2 | - * @Author: zhuoyuan93@gmail.com | ||
| 3 | - * @Date: 2018-10-16 19:43:03 | ||
| 4 | - * @LastEditors: zhuoyuan93@gmail.com | ||
| 5 | - * @LastEditTime: 2020年6月20日 11:20:02 | ||
| 6 | - * @Description: Update log | ||
| 7 | - --> | 1 | +# 5.0.0-nullsafety.0 |
| 2 | +- Migrated flutter_screenutil to non-nullable | ||
| 8 | 3 | ||
| 9 | # 4.0.0-beta3 | 4 | # 4.0.0-beta3 |
| 10 | - Optimize the way of initialization | 5 | - Optimize the way of initialization |
| @@ -16,54 +16,14 @@ dependencies: | @@ -16,54 +16,14 @@ dependencies: | ||
| 16 | flutter: | 16 | flutter: |
| 17 | sdk: flutter | 17 | sdk: flutter |
| 18 | 18 | ||
| 19 | - # The following adds the Cupertino Icons font to your application. | ||
| 20 | - # Use with the CupertinoIcons class for iOS style icons. | ||
| 21 | - cupertino_icons: ^0.1.2 | ||
| 22 | flutter_screenutil: | 19 | flutter_screenutil: |
| 23 | - path: ../ | 20 | + |
| 24 | dev_dependencies: | 21 | dev_dependencies: |
| 25 | flutter_test: | 22 | flutter_test: |
| 26 | sdk: flutter | 23 | sdk: flutter |
| 24 | + test: ^1.15.7 | ||
| 27 | 25 | ||
| 26 | +dependency_overrides: | ||
| 27 | + flutter_screenutil: | ||
| 28 | + path: ../ | ||
| 28 | 29 | ||
| 29 | -# For information on the generic Dart part of this file, see the | ||
| 30 | -# following page: https://www.dartlang.org/tools/pub/pubspec | ||
| 31 | - | ||
| 32 | -# The following section is specific to Flutter. | ||
| 33 | -flutter: | ||
| 34 | - | ||
| 35 | - # The following line ensures that the Material Icons font is | ||
| 36 | - # included with your application, so that you can use the icons in | ||
| 37 | - # the material Icons class. | ||
| 38 | - uses-material-design: true | ||
| 39 | - | ||
| 40 | - # To add assets to your application, add an assets section, like this: | ||
| 41 | - # assets: | ||
| 42 | - # - images/a_dot_burr.jpeg | ||
| 43 | - # - images/a_dot_ham.jpeg | ||
| 44 | - | ||
| 45 | - # An image asset can refer to one or more resolution-specific "variants", see | ||
| 46 | - # https://flutter.io/assets-and-images/#resolution-aware. | ||
| 47 | - | ||
| 48 | - # For details regarding adding assets from package dependencies, see | ||
| 49 | - # https://flutter.io/assets-and-images/#from-packages | ||
| 50 | - | ||
| 51 | - # To add custom fonts to your application, add a fonts section here, | ||
| 52 | - # in this "flutter" section. Each entry in this list should have a | ||
| 53 | - # "family" key with the font family name, and a "fonts" key with a | ||
| 54 | - # list giving the asset and other descriptors for the font. For | ||
| 55 | - # example: | ||
| 56 | - # fonts: | ||
| 57 | - # - family: Schyler | ||
| 58 | - # fonts: | ||
| 59 | - # - asset: fonts/Schyler-Regular.ttf | ||
| 60 | - # - asset: fonts/Schyler-Italic.ttf | ||
| 61 | - # style: italic | ||
| 62 | - # - family: Trajan Pro | ||
| 63 | - # fonts: | ||
| 64 | - # - asset: fonts/TrajanPro.ttf | ||
| 65 | - # - asset: fonts/TrajanPro_Bold.ttf | ||
| 66 | - # weight: 700 | ||
| 67 | - # | ||
| 68 | - # For details regarding fonts from package dependencies, | ||
| 69 | - # see https://flutter.io/custom-fonts/#from-packages |
| @@ -8,30 +8,26 @@ import 'dart:ui' as ui; | @@ -8,30 +8,26 @@ import 'dart:ui' as ui; | ||
| 8 | 8 | ||
| 9 | class ScreenUtil { | 9 | class ScreenUtil { |
| 10 | static const Size defaultSize = Size(1080, 1920); | 10 | static const Size defaultSize = Size(1080, 1920); |
| 11 | - static ScreenUtil _instance; | 11 | + static late ScreenUtil _instance; |
| 12 | 12 | ||
| 13 | /// UI设计中手机尺寸 , px | 13 | /// UI设计中手机尺寸 , px |
| 14 | /// Size of the phone in UI Design , px | 14 | /// Size of the phone in UI Design , px |
| 15 | - Size uiSize; | 15 | + late Size uiSize; |
| 16 | 16 | ||
| 17 | /// 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。 | 17 | /// 控制字体是否要根据系统的“字体大小”辅助选项来进行缩放。默认值为false。 |
| 18 | /// allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false. | 18 | /// allowFontScaling Specifies whether fonts should scale to respect Text Size accessibility settings. The default is false. |
| 19 | - bool allowFontScaling; | 19 | + late bool allowFontScaling; |
| 20 | 20 | ||
| 21 | - static double _pixelRatio; | ||
| 22 | - static double _textScaleFactor; | ||
| 23 | - static double _screenWidth; | ||
| 24 | - static double _screenHeight; | ||
| 25 | - static double _statusBarHeight; | ||
| 26 | - static double _bottomBarHeight; | 21 | + static late double _pixelRatio; |
| 22 | + static late double _textScaleFactor; | ||
| 23 | + static late double _screenWidth; | ||
| 24 | + static late double _screenHeight; | ||
| 25 | + static late double _statusBarHeight; | ||
| 26 | + static late double _bottomBarHeight; | ||
| 27 | 27 | ||
| 28 | ScreenUtil._(); | 28 | ScreenUtil._(); |
| 29 | 29 | ||
| 30 | factory ScreenUtil() { | 30 | factory ScreenUtil() { |
| 31 | - assert( | ||
| 32 | - _instance != null, | ||
| 33 | - '\nEnsure to initialize ScreenUtil before accessing it.\nPlease execute the init method : ScreenUtil.init()', | ||
| 34 | - ); | ||
| 35 | return _instance; | 31 | return _instance; |
| 36 | } | 32 | } |
| 37 | 33 | ||
| @@ -40,7 +36,7 @@ class ScreenUtil { | @@ -40,7 +36,7 @@ class ScreenUtil { | ||
| 40 | Size designSize = defaultSize, | 36 | Size designSize = defaultSize, |
| 41 | bool allowFontScaling = false, | 37 | bool allowFontScaling = false, |
| 42 | }) { | 38 | }) { |
| 43 | - _instance ??= ScreenUtil._(); | 39 | + _instance = ScreenUtil._(); |
| 44 | _instance | 40 | _instance |
| 45 | ..uiSize = designSize | 41 | ..uiSize = designSize |
| 46 | ..allowFontScaling = allowFontScaling; | 42 | ..allowFontScaling = allowFontScaling; |
| @@ -116,7 +112,7 @@ class ScreenUtil { | @@ -116,7 +112,7 @@ class ScreenUtil { | ||
| 116 | ///Font size adaptation method | 112 | ///Font size adaptation method |
| 117 | ///- [fontSize] The size of the font on the UI design, in px. | 113 | ///- [fontSize] The size of the font on the UI design, in px. |
| 118 | ///- [allowFontScaling] | 114 | ///- [allowFontScaling] |
| 119 | - double setSp(num fontSize, {bool allowFontScalingSelf}) => | 115 | + double setSp(num fontSize, {bool? allowFontScalingSelf}) => |
| 120 | allowFontScalingSelf == null | 116 | allowFontScalingSelf == null |
| 121 | ? (allowFontScaling | 117 | ? (allowFontScaling |
| 122 | ? (fontSize * scaleText) | 118 | ? (fontSize * scaleText) |
| @@ -5,10 +5,10 @@ import 'screenutil.dart'; | @@ -5,10 +5,10 @@ import 'screenutil.dart'; | ||
| 5 | class ScreenUtilInit extends StatelessWidget { | 5 | class ScreenUtilInit extends StatelessWidget { |
| 6 | /// A helper widget that initializes [ScreenUtil] | 6 | /// A helper widget that initializes [ScreenUtil] |
| 7 | ScreenUtilInit({ | 7 | ScreenUtilInit({ |
| 8 | - @required this.child, | 8 | + required this.child, |
| 9 | this.designSize = ScreenUtil.defaultSize, | 9 | this.designSize = ScreenUtil.defaultSize, |
| 10 | this.allowFontScaling = false, | 10 | this.allowFontScaling = false, |
| 11 | - Key key, | 11 | + Key? key, |
| 12 | }) : super(key: key); | 12 | }) : super(key: key); |
| 13 | 13 | ||
| 14 | final Widget child; | 14 | final Widget child; |
| 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: 4.0.0-beta3 | 3 | +version: 5.0.0-nullsafety.0 |
| 4 | homepage: https://github.com/OpenFlutter/flutter_screenutil | 4 | homepage: https://github.com/OpenFlutter/flutter_screenutil |
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
| 7 | - sdk: ">=2.6.0 <3.0.0" | 7 | + sdk: '>=2.12.0-29.10.beta <3.0.0' |
| 8 | 8 | ||
| 9 | dependencies: | 9 | dependencies: |
| 10 | flutter: | 10 | flutter: |
-
Please register or login to post a comment