李卓原

修复高度不准确的问题

适配2.10
... ... @@ -6,7 +6,7 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="flutter_screenutil"
android:icon="@mipmap/ic_launcher">
<activity
... ...
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
... ...
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/app/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/app/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/app/src/main/assets" />
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/app/src/main/libs" />
<option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/app/src/main/proguard_logs" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/app/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/app/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>
<orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Flutter for Android" level="project" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\dev\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\kagee\Documents\flutter_screenutil\example"
export "FLUTTER_ROOT=/Users/lizhuoyuan/Development/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
<<<<<<< HEAD
export "FLUTTER_TARGET=lib\main.dart"
=======
export "FLUTTER_TARGET=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/lib/main.dart"
>>>>>>> 30a18a0ab24cfbb7f41bc5abd3b88e91b091d595
export "FLUTTER_TARGET=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=="
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/.dart_tool/package_config.json"
export "PACKAGE_CONFIG=.packages"
... ...
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
void main() {
... ... @@ -143,12 +144,22 @@ class _HomePageState extends State<HomePage> {
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
SystemChrome.setPreferredOrientations([
MediaQuery.of(context).orientation == Orientation.portrait
? DeviceOrientation.landscapeRight
: DeviceOrientation.portraitUp,
]);
// setState(() {});
},
child: Icon(Icons.screen_rotation),
),
);
}
void printScreenInformation() {
print('Device width dp:${1.sw}dp');
print('Device height dp:${1.sh}dp');
print('Device Size:${Size(1.sw, 1.sh)}');
print('Device pixel density:${ScreenUtil().pixelRatio}');
print('Bottom safe zone distance dp:${ScreenUtil().bottomBarHeight}dp');
print('Status bar height dp:${ScreenUtil().statusBarHeight}dp');
... ...
... ... @@ -19,6 +19,7 @@ class ScreenUtil {
late double _screenHeight;
late bool _minTextAdapt;
late BuildContext? context;
late bool _splitScreenMode;
ScreenUtil._();
... ... @@ -40,12 +41,11 @@ class ScreenUtil {
}) {
_instance = ScreenUtil._()
..uiSize = designSize
.._splitScreenMode = splitScreenMode
.._minTextAdapt = minTextAdapt
.._orientation = orientation
.._screenWidth = constraints.maxWidth
.._screenHeight = splitScreenMode
? max(constraints.maxHeight, 700)
: constraints.maxHeight;
.._screenHeight = constraints.maxHeight;
if (context != null) setContext(context);
}
... ... @@ -82,7 +82,9 @@ class ScreenUtil {
double get scaleWidth => screenWidth / uiSize.width;
/// /// The ratio of actual height to UI design
double get scaleHeight => screenHeight / uiSize.height;
double get scaleHeight =>
(_splitScreenMode ? max(screenHeight, 700) : screenHeight) /
uiSize.height;
double get scaleText =>
_minTextAdapt ? min(scaleWidth, scaleHeight) : scaleWidth;
... ...