From 5e6d317f23b91ea45a4a9e623d735d5af48e2962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=8D=93=E5=8E=9F?= Date: Mon, 21 Aug 2023 16:08:27 +0800 Subject: [PATCH] v5.9.0 --- CHANGELOG.md | 3 +- .../ios/Flutter/flutter_export_environment.sh | 5 +-- lib/src/screen_util.dart | 34 +++++++++++++++++++ pubspec.yaml | 2 +- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43f9476..a22f0a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ -# 5.9.0-beta +# 5.9.0 - ScreenUtilInit won't rebuild the whole widget tree - Add `fontSizeResolver` to specify how font size should be scaled - Add `diameter` & `diagonal` factors - `useInheritedMediaQuery` has not effect, and will be removed in next release - Fix `ensureScreenSize` in web platform +- add deviceType # 5.8.4 - bug fix diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 4a3c589..eae3356 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -3,11 +3,12 @@ export "FLUTTER_ROOT=/Users/lizhuoyuan/fvm/versions/stable" export "FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_TARGET=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" +export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC9jZGJlZGE3ODhhMjkzZmEyOTY2NWRjM2ZhM2Q2ZTYzYmQyMjFjYjBkLw==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" +export "PACKAGE_CONFIG=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/.dart_tool/package_config.json" diff --git a/lib/src/screen_util.dart b/lib/src/screen_util.dart index 477d7db..1655057 100644 --- a/lib/src/screen_util.dart +++ b/lib/src/screen_util.dart @@ -3,6 +3,7 @@ * email: zhuoyuan93@gmail.com */ +import 'dart:io'; import 'dart:math' show min, max; import 'dart:ui' as ui show FlutterView; @@ -240,6 +241,37 @@ class ScreenUtil { double setSp(num fontSize) => fontSizeResolver?.call(fontSize, _instance) ?? fontSize * scaleText; + DeviceType deviceType() { + DeviceType deviceType; + switch (Platform.operatingSystem) { + case 'android': + case 'ios': + deviceType = DeviceType.mobile; + if ((orientation == Orientation.portrait && screenWidth < 600) || + (orientation == Orientation.landscape && screenHeight < 600)) { + deviceType = DeviceType.mobile; + } else { + deviceType = DeviceType.tablet; + } + break; + case 'linux': + deviceType = DeviceType.linux; + break; + case 'macos': + deviceType = DeviceType.mac; + break; + case 'windows': + deviceType = DeviceType.windows; + break; + case 'fuchsia': + deviceType = DeviceType.fuchsia; + break; + default: + deviceType = DeviceType.web; + } + return deviceType; + } + SizedBox setVerticalSpacing(num height) => SizedBox(height: setHeight(height)); @@ -275,3 +307,5 @@ extension on MediaQueryData? { return this; } } + +enum DeviceType { mobile, tablet, web, mac, windows, linux, fuchsia } diff --git a/pubspec.yaml b/pubspec.yaml index 3fe691d..6bc508c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_screenutil description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models -version: 5.9.0-beta +version: 5.9.0 homepage: https://github.com/OpenFlutter/flutter_screenutil environment: