Skip to content

Commit 5e6d317

Browse files
author
李卓原
committed
v5.9.0
1 parent 7c8d2cc commit 5e6d317

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# 5.9.0-beta
1+
# 5.9.0
22
- ScreenUtilInit won't rebuild the whole widget tree
33
- Add `fontSizeResolver` to specify how font size should be scaled
44
- Add `diameter` & `diagonal` factors
55
- `useInheritedMediaQuery` has not effect, and will be removed in next release
66
- Fix `ensureScreenSize` in web platform
7+
- add deviceType
78

89
# 5.8.4
910
- bug fix

example/ios/Flutter/flutter_export_environment.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
export "FLUTTER_ROOT=/Users/lizhuoyuan/fvm/versions/stable"
44
export "FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example"
55
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
6-
export "FLUTTER_TARGET=lib/main.dart"
6+
export "FLUTTER_TARGET=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/lib/main.dart"
77
export "FLUTTER_BUILD_DIR=build"
88
export "FLUTTER_BUILD_NAME=1.0.0"
99
export "FLUTTER_BUILD_NUMBER=1"
10+
export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC9jZGJlZGE3ODhhMjkzZmEyOTY2NWRjM2ZhM2Q2ZTYzYmQyMjFjYjBkLw=="
1011
export "DART_OBFUSCATION=false"
1112
export "TRACK_WIDGET_CREATION=true"
1213
export "TREE_SHAKE_ICONS=false"
13-
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
14+
export "PACKAGE_CONFIG=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/.dart_tool/package_config.json"

lib/src/screen_util.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* email: zhuoyuan93@gmail.com
44
*/
55

6+
import 'dart:io';
67
import 'dart:math' show min, max;
78
import 'dart:ui' as ui show FlutterView;
89

@@ -240,6 +241,37 @@ class ScreenUtil {
240241
double setSp(num fontSize) =>
241242
fontSizeResolver?.call(fontSize, _instance) ?? fontSize * scaleText;
242243

244+
DeviceType deviceType() {
245+
DeviceType deviceType;
246+
switch (Platform.operatingSystem) {
247+
case 'android':
248+
case 'ios':
249+
deviceType = DeviceType.mobile;
250+
if ((orientation == Orientation.portrait && screenWidth < 600) ||
251+
(orientation == Orientation.landscape && screenHeight < 600)) {
252+
deviceType = DeviceType.mobile;
253+
} else {
254+
deviceType = DeviceType.tablet;
255+
}
256+
break;
257+
case 'linux':
258+
deviceType = DeviceType.linux;
259+
break;
260+
case 'macos':
261+
deviceType = DeviceType.mac;
262+
break;
263+
case 'windows':
264+
deviceType = DeviceType.windows;
265+
break;
266+
case 'fuchsia':
267+
deviceType = DeviceType.fuchsia;
268+
break;
269+
default:
270+
deviceType = DeviceType.web;
271+
}
272+
return deviceType;
273+
}
274+
243275
SizedBox setVerticalSpacing(num height) =>
244276
SizedBox(height: setHeight(height));
245277

@@ -275,3 +307,5 @@ extension on MediaQueryData? {
275307
return this;
276308
}
277309
}
310+
311+
enum DeviceType { mobile, tablet, web, mac, windows, linux, fuchsia }

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_screenutil
22
description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
3-
version: 5.9.0-beta
3+
version: 5.9.0
44
homepage: https://github.com/OpenFlutter/flutter_screenutil
55

66
environment:

0 commit comments

Comments
 (0)