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
李卓原
2020-11-27 16:26:53 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4fb14b1b3e1f4e4214176f6368a038e5061deec8
4fb14b1b
1 parent
e5b00e51
4.0.0-beta readme
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
155 deletions
README.md
README_CN.md
README_PT.md
example/ios/Flutter/flutter_export_environment.sh
example/ios/Runner.xcodeproj/project.pbxproj
example/lib/main.dart
example/lib/main_zh.dart
README.md
View file @
4fb14b1
...
...
@@ -190,7 +190,7 @@ Column(
### Example:
[
example demo
](
/example/lib/main
.dart
)
[
example demo
](
https://github.com/OpenFlutter/flutter_screenutil/blob/master/example/lib/main_zh
.dart
)
### Effect:
...
...
README_CN.md
View file @
4fb14b1
...
...
@@ -184,145 +184,12 @@ Column(
)
```
```
dart
import
'package:flutter/material.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
void
main
(
)
=>
runApp
(
MyApp
());
class
MyApp
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
LayoutBuilder
(
builder:
(
context
,
constraints
)
{
//Set the fit size (fill in the screen size of the device in the design) If the design is based on the size of the iPhone6 (iPhone6 750*1334)
ScreenUtil
.
init
(
constraints
,
designSize:
Size
(
750
,
1334
),
allowFontScaling:
false
);
return
MaterialApp
(
debugShowCheckedModeBanner:
false
,
title:
'Flutter_ScreenUtil'
,
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
,
),
home:
HomePage
(
title:
'FlutterScreenUtil Demo'
),
);
},
);
}
}
class
HomePage
extends
StatefulWidget
{
const
HomePage
({
Key
key
,
this
.
title
})
:
super
(
key:
key
);
final
String
title
;
@override
_HomePageState
createState
()
=>
_HomePageState
();
}
class
_HomePageState
extends
State
<
HomePage
>
{
@override
Widget
build
(
BuildContext
context
)
{
printScreenInformation
();
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
widget
.
title
),
),
body:
SingleChildScrollView
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
Row
(
children:
<
Widget
>[
Container
(
padding:
EdgeInsets
.
all
(
ScreenUtil
().
setWidth
(
10
)),
width:
ScreenUtil
().
setWidth
(
375
),
height:
ScreenUtil
().
setHeight
(
200
),
color:
Colors
.
red
,
child:
Text
(
'我的宽度:
${0.5.sw}
dp
\n
'
'我的高度:
${ScreenUtil().setHeight(200)}
dp'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
ScreenUtil
().
setSp
(
24
)),
),
),
Container
(
padding:
EdgeInsets
.
all
(
ScreenUtil
().
setWidth
(
10
)),
width:
375
.
w
,
height:
200
.
h
,
color:
Colors
.
blue
,
child:
Text
(
'我的宽度:
${375.w}
dp
\n
'
'我的高度:
${200.h}
dp'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
ScreenUtil
().
setSp
(
24
))),
),
],
),
Text
(
'设备宽度:
${ScreenUtil().screenWidthPx}
px'
),
Text
(
'设备高度:
${ScreenUtil().screenHeightPx}
px'
),
Text
(
'设备宽度:
${ScreenUtil().screenWidth}
dp'
),
Text
(
'设备高度:
${ScreenUtil().screenHeight}
dp'
),
Text
(
'设备的像素密度:
${ScreenUtil().pixelRatio}
'
),
Text
(
'底部安全区距离:
${ScreenUtil().bottomBarHeight}
dp'
),
Text
(
'状态栏高度:
${ScreenUtil().statusBarHeight}
dp'
),
Text
(
'实际宽度的dp与设计稿px的比例:
${ScreenUtil().scaleWidth}
'
,
textAlign:
TextAlign
.
center
,
),
Text
(
'实际高度的dp与设计稿px的比例:
${ScreenUtil().scaleHeight}
'
,
textAlign:
TextAlign
.
center
,
),
SizedBox
(
height:
100
.
h
,
),
Text
(
'系统的字体缩放比例:
${ScreenUtil().textScaleFactor}
'
),
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Text
(
'我的文字大小在设计稿上是24px,不会随着系统的文字缩放比例变化'
,
style:
TextStyle
(
color:
Colors
.
black
,
fontSize:
24
.
sp
,
),
),
Text
(
'我的文字大小在设计稿上是24px,会随着系统的文字缩放比例变化'
,
style:
TextStyle
(
color:
Colors
.
black
,
fontSize:
24
.
ssp
,
),
),
],
)
],
),
),
);
}
void
printScreenInformation
()
{
print
(
'设备宽度:
${1.sw}
'
);
print
(
'设备高度:
${1.sh}
'
);
print
(
'设备的像素密度:
${ScreenUtil().pixelRatio}
'
);
print
(
'底部安全区距离:
${ScreenUtil().bottomBarHeight}
dp'
);
print
(
'状态栏高度:
${ScreenUtil().statusBarHeight}
dp'
);
print
(
'实际宽度的dp与设计稿px的比例:
${ScreenUtil().scaleWidth}
'
);
print
(
'实际高度的dp与设计稿px的比例:
${ScreenUtil().scaleHeight}
'
);
print
(
'宽度和字体相对于设计稿放大的比例:
${ScreenUtil().scaleWidth * ScreenUtil().pixelRatio}
'
);
print
(
'高度相对于设计稿放大的比例:
${ScreenUtil().scaleHeight * ScreenUtil().pixelRatio}
'
);
print
(
'系统的字体缩放比例:
${ScreenUtil().textScaleFactor}
'
);
print
(
'屏幕宽度的0.5:
${0.5.sw}
'
);
print
(
'屏幕高度的0.5:
${0.5.sh}
'
);
}
}
```
[
widget test
](
https://github.com/OpenFlutter/flutter_screenutil/issues/115
)
### 使用示例:
[
example demo
](
https://github.com/OpenFlutter/flutter_
ScreenU
til/blob/master/example/lib/main_zh.dart
)
[
example demo
](
https://github.com/OpenFlutter/flutter_
screenu
til/blob/master/example/lib/main_zh.dart
)
效果:
...
...
README_PT.md
View file @
4fb14b1
...
...
@@ -333,7 +333,7 @@ class _HomePageState extends State<HomePage> {
### Exemplo:
[
Demonstração
](
/example/lib/main_zh.dart
)
[
Demonstração
](
https://github.com/OpenFlutter/flutter_screenutil/blob/master
/example/lib/main_zh.dart
)
Efeito:
...
...
example/ios/Flutter/flutter_export_environment.sh
View file @
4fb14b1
...
...
@@ -2,10 +2,14 @@
# This is a generated file; do not edit or check into version control.
export
"FLUTTER_ROOT=/Users/lizhuoyuan/Development/flutter"
export
"FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_screenutil/example"
export
"FLUTTER_TARGET=
/Users/lizhuoyuan/Development/Project/flutter_screenutil/example/
lib/main.dart"
export
"FLUTTER_TARGET=lib/main.dart"
export
"FLUTTER_BUILD_DIR=build"
export
"SYMROOT=
${
SOURCE_ROOT
}
/../build/ios"
export
"FLUTTER_FRAMEWORK_DIR=/Users/lizhuoyuan/Development/flutter/bin/cache/artifacts/engine/ios"
export
"OTHER_LDFLAGS=
$(
inherited
)
-framework Flutter"
export
"FLUTTER_FRAMEWORK_DIR=/Users/lizhuoyuan/Development/flutter/bin/cache/artifacts/engine/ios-release"
export
"FLUTTER_BUILD_NAME=1.0.0"
export
"FLUTTER_BUILD_NUMBER=1"
export
"TRACK_WIDGET_CREATION=true"
export
"DART_OBFUSCATION=false"
export
"TRACK_WIDGET_CREATION=false"
export
"TREE_SHAKE_ICONS=true"
export
"PACKAGE_CONFIG=.packages"
...
...
example/ios/Runner.xcodeproj/project.pbxproj
View file @
4fb14b1
...
...
@@ -9,10 +9,6 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
...
...
@@ -28,8 +24,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
...
...
@@ -40,13 +34,11 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
...
...
@@ -60,8 +52,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
...
...
@@ -71,9 +61,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
...
...
@@ -87,7 +75,6 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
);
sourceTree = "<group>";
};
...
...
@@ -165,6 +152,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
...
...
@@ -206,7 +194,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\"
embed_and_
thin";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
...
...
@@ -259,7 +247,6 @@
/* Begin XCBuildConfiguration section */
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
...
...
@@ -313,7 +300,6 @@
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
...
...
@@ -365,6 +351,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
...
...
@@ -388,6 +375,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = E4T4EJGC8Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
...
...
example/lib/main.dart
View file @
4fb14b1
...
...
@@ -16,6 +16,7 @@ class MyApp extends StatelessWidget {
title:
'Flutter_ScreenUtil'
,
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
,
textTheme:
TextTheme
(
button:
TextStyle
(
fontSize:
80
.
nsp
)),
),
home:
HomePage
(
title:
'FlutterScreenUtil Demo'
),
);
...
...
@@ -47,6 +48,7 @@ class _HomePageState extends State<HomePage> {
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
TextButton
(
onPressed:
null
,
child:
Text
(
'text'
)),
Row
(
children:
<
Widget
>[
// Using Extensions
...
...
example/lib/main_zh.dart
View file @
4fb14b1
...
...
@@ -16,6 +16,7 @@ class MyApp extends StatelessWidget {
title:
'Flutter_ScreenUtil'
,
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
,
textTheme:
TextTheme
(
button:
TextStyle
(
fontSize:
80
.
nsp
)),
),
home:
HomePage
(
title:
'FlutterScreenUtil Demo'
),
);
...
...
Please
register
or
login
to post a comment