Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
flutter_screenutil
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
李卓原
2022-02-10 14:48:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6d42e28bd7d1505ce73b21c0c251936c908b4a0f
6d42e28b
1 parent
32d5fcb3
修复高度不准确的问题
适配2.10
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
57 deletions
example/android/app/src/main/AndroidManifest.xml
example/android/build.gradle
example/android/example_android.iml
example/android/gradle.properties
example/android/gradle/wrapper/gradle-wrapper.properties
example/ios/Flutter/flutter_export_environment.sh
example/lib/main.dart
lib/screen_util.dart
example/android/app/src/main/AndroidManifest.xml
View file @
6d42e28
...
...
@@ -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
...
...
example/android/build.gradle
View file @
6d42e28
buildscript
{
ext
.
kotlin_version
=
'1.
3.5
0'
ext
.
kotlin_version
=
'1.
6.1
0'
repositories
{
google
()
jcenter
()
...
...
example/android/example_android.iml
deleted
100644 → 0
View file @
32d5fcb
<?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>
example/android/gradle.properties
deleted
100644 → 0
View file @
32d5fcb
org.gradle.jvmargs
=
-Xmx1536M
android.enableR8
=
true
android.useAndroidX
=
true
android.enableJetifier
=
true
example/android/gradle/wrapper/gradle-wrapper.properties
deleted
100644 → 0
View file @
32d5fcb
#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
example/ios/Flutter/flutter_export_environment.sh
View file @
6d42e28
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export
"FLUTTER_ROOT=C:
\d
ev
\f
lutter"
export
"FLUTTER_APPLICATION_PATH=C:
\U
sers
\k
agee
\D
ocuments
\f
lutter_screenutil
\e
xample"
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
\m
ain.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=
tru
e"
export
"TRACK_WIDGET_CREATION=
fals
e"
export
"TREE_SHAKE_ICONS=false"
export
"PACKAGE_CONFIG=
/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/.dart_tool/package_config.json
"
export
"PACKAGE_CONFIG=
.packages
"
...
...
example/lib/main.dart
View file @
6d42e28
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'
);
...
...
lib/screen_util.dart
View file @
6d42e28
...
...
@@ -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
;
...
...
Please
register
or
login
to post a comment