Showing
8 changed files
with
26 additions
and
57 deletions
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | additional functionality it is fine to subclass or reimplement | 6 | additional functionality it is fine to subclass or reimplement |
| 7 | FlutterApplication and put your custom class here. --> | 7 | FlutterApplication and put your custom class here. --> |
| 8 | <application | 8 | <application |
| 9 | - android:name="io.flutter.app.FlutterApplication" | 9 | + android:name="${applicationName}" |
| 10 | android:label="flutter_screenutil" | 10 | android:label="flutter_screenutil" |
| 11 | android:icon="@mipmap/ic_launcher"> | 11 | android:icon="@mipmap/ic_launcher"> |
| 12 | <activity | 12 | <activity |
example/android/example_android.iml
deleted
100644 → 0
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<module type="JAVA_MODULE" version="4"> | ||
| 3 | - <component name="FacetManager"> | ||
| 4 | - <facet type="android" name="Android"> | ||
| 5 | - <configuration> | ||
| 6 | - <option name="ALLOW_USER_CONFIGURATION" value="false" /> | ||
| 7 | - <option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" /> | ||
| 8 | - <option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" /> | ||
| 9 | - <option name="MANIFEST_FILE_RELATIVE_PATH" value="/app/src/main/AndroidManifest.xml" /> | ||
| 10 | - <option name="RES_FOLDER_RELATIVE_PATH" value="/app/src/main/res" /> | ||
| 11 | - <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/app/src/main/assets" /> | ||
| 12 | - <option name="LIBS_FOLDER_RELATIVE_PATH" value="/app/src/main/libs" /> | ||
| 13 | - <option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/app/src/main/proguard_logs" /> | ||
| 14 | - </configuration> | ||
| 15 | - </facet> | ||
| 16 | - </component> | ||
| 17 | - <component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
| 18 | - <exclude-output /> | ||
| 19 | - <content url="file://$MODULE_DIR$"> | ||
| 20 | - <sourceFolder url="file://$MODULE_DIR$/app/src/main/java" isTestSource="false" /> | ||
| 21 | - <sourceFolder url="file://$MODULE_DIR$/app/src/main/kotlin" isTestSource="false" /> | ||
| 22 | - <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" /> | ||
| 23 | - </content> | ||
| 24 | - <orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" /> | ||
| 25 | - <orderEntry type="sourceFolder" forTests="false" /> | ||
| 26 | - <orderEntry type="library" name="Flutter for Android" level="project" /> | ||
| 27 | - <orderEntry type="library" name="KotlinJavaRuntime" level="project" /> | ||
| 28 | - </component> | ||
| 29 | -</module> |
example/android/gradle.properties
deleted
100644 → 0
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | # This is a generated file; do not edit or check into version control. | 2 | # This is a generated file; do not edit or check into version control. |
| 3 | -export "FLUTTER_ROOT=C:\dev\flutter" | ||
| 4 | -export "FLUTTER_APPLICATION_PATH=C:\Users\kagee\Documents\flutter_screenutil\example" | 3 | +export "FLUTTER_ROOT=/Users/lizhuoyuan/Development/flutter" |
| 4 | +export "FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example" | ||
| 5 | export "COCOAPODS_PARALLEL_CODE_SIGN=true" | 5 | export "COCOAPODS_PARALLEL_CODE_SIGN=true" |
| 6 | -<<<<<<< HEAD | ||
| 7 | -export "FLUTTER_TARGET=lib\main.dart" | ||
| 8 | -======= | ||
| 9 | -export "FLUTTER_TARGET=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/lib/main.dart" | ||
| 10 | ->>>>>>> 30a18a0ab24cfbb7f41bc5abd3b88e91b091d595 | 6 | +export "FLUTTER_TARGET=lib/main.dart" |
| 11 | export "FLUTTER_BUILD_DIR=build" | 7 | export "FLUTTER_BUILD_DIR=build" |
| 12 | export "FLUTTER_BUILD_NAME=1.0.0" | 8 | export "FLUTTER_BUILD_NAME=1.0.0" |
| 13 | export "FLUTTER_BUILD_NUMBER=1" | 9 | export "FLUTTER_BUILD_NUMBER=1" |
| 14 | -export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" | ||
| 15 | export "DART_OBFUSCATION=false" | 10 | export "DART_OBFUSCATION=false" |
| 16 | -export "TRACK_WIDGET_CREATION=true" | 11 | +export "TRACK_WIDGET_CREATION=false" |
| 17 | export "TREE_SHAKE_ICONS=false" | 12 | export "TREE_SHAKE_ICONS=false" |
| 18 | -export "PACKAGE_CONFIG=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/.dart_tool/package_config.json" | 13 | +export "PACKAGE_CONFIG=.packages" |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter/services.dart'; | ||
| 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | 4 | ||
| 4 | void main() { | 5 | void main() { |
| @@ -143,12 +144,22 @@ class _HomePageState extends State<HomePage> { | @@ -143,12 +144,22 @@ class _HomePageState extends State<HomePage> { | ||
| 143 | ], | 144 | ], |
| 144 | ), | 145 | ), |
| 145 | ), | 146 | ), |
| 147 | + floatingActionButton: FloatingActionButton( | ||
| 148 | + onPressed: () { | ||
| 149 | + SystemChrome.setPreferredOrientations([ | ||
| 150 | + MediaQuery.of(context).orientation == Orientation.portrait | ||
| 151 | + ? DeviceOrientation.landscapeRight | ||
| 152 | + : DeviceOrientation.portraitUp, | ||
| 153 | + ]); | ||
| 154 | + // setState(() {}); | ||
| 155 | + }, | ||
| 156 | + child: Icon(Icons.screen_rotation), | ||
| 157 | + ), | ||
| 146 | ); | 158 | ); |
| 147 | } | 159 | } |
| 148 | 160 | ||
| 149 | void printScreenInformation() { | 161 | void printScreenInformation() { |
| 150 | - print('Device width dp:${1.sw}dp'); | ||
| 151 | - print('Device height dp:${1.sh}dp'); | 162 | + print('Device Size:${Size(1.sw, 1.sh)}'); |
| 152 | print('Device pixel density:${ScreenUtil().pixelRatio}'); | 163 | print('Device pixel density:${ScreenUtil().pixelRatio}'); |
| 153 | print('Bottom safe zone distance dp:${ScreenUtil().bottomBarHeight}dp'); | 164 | print('Bottom safe zone distance dp:${ScreenUtil().bottomBarHeight}dp'); |
| 154 | print('Status bar height dp:${ScreenUtil().statusBarHeight}dp'); | 165 | print('Status bar height dp:${ScreenUtil().statusBarHeight}dp'); |
| @@ -19,6 +19,7 @@ class ScreenUtil { | @@ -19,6 +19,7 @@ class ScreenUtil { | ||
| 19 | late double _screenHeight; | 19 | late double _screenHeight; |
| 20 | late bool _minTextAdapt; | 20 | late bool _minTextAdapt; |
| 21 | late BuildContext? context; | 21 | late BuildContext? context; |
| 22 | + late bool _splitScreenMode; | ||
| 22 | 23 | ||
| 23 | ScreenUtil._(); | 24 | ScreenUtil._(); |
| 24 | 25 | ||
| @@ -40,12 +41,11 @@ class ScreenUtil { | @@ -40,12 +41,11 @@ class ScreenUtil { | ||
| 40 | }) { | 41 | }) { |
| 41 | _instance = ScreenUtil._() | 42 | _instance = ScreenUtil._() |
| 42 | ..uiSize = designSize | 43 | ..uiSize = designSize |
| 44 | + .._splitScreenMode = splitScreenMode | ||
| 43 | .._minTextAdapt = minTextAdapt | 45 | .._minTextAdapt = minTextAdapt |
| 44 | .._orientation = orientation | 46 | .._orientation = orientation |
| 45 | .._screenWidth = constraints.maxWidth | 47 | .._screenWidth = constraints.maxWidth |
| 46 | - .._screenHeight = splitScreenMode | ||
| 47 | - ? max(constraints.maxHeight, 700) | ||
| 48 | - : constraints.maxHeight; | 48 | + .._screenHeight = constraints.maxHeight; |
| 49 | if (context != null) setContext(context); | 49 | if (context != null) setContext(context); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| @@ -82,7 +82,9 @@ class ScreenUtil { | @@ -82,7 +82,9 @@ class ScreenUtil { | ||
| 82 | double get scaleWidth => screenWidth / uiSize.width; | 82 | double get scaleWidth => screenWidth / uiSize.width; |
| 83 | 83 | ||
| 84 | /// /// The ratio of actual height to UI design | 84 | /// /// The ratio of actual height to UI design |
| 85 | - double get scaleHeight => screenHeight / uiSize.height; | 85 | + double get scaleHeight => |
| 86 | + (_splitScreenMode ? max(screenHeight, 700) : screenHeight) / | ||
| 87 | + uiSize.height; | ||
| 86 | 88 | ||
| 87 | double get scaleText => | 89 | double get scaleText => |
| 88 | _minTextAdapt ? min(scaleWidth, scaleHeight) : scaleWidth; | 90 | _minTextAdapt ? min(scaleWidth, scaleHeight) : scaleWidth; |
-
Please register or login to post a comment