diff --git a/README.md b/README.md index f5b1542..8048e89 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/README_CN.md b/README_CN.md index 8f59426..10df59e 100644 --- a/README_CN.md +++ b/README_CN.md @@ -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 { - @override - Widget build(BuildContext context) { - printScreenInformation(); - return Scaffold( - appBar: AppBar( - title: Text(widget.title), - ), - body: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - children: [ - 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: [ - 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_ScreenUtil/blob/master/example/lib/main_zh.dart) +[example demo](https://github.com/OpenFlutter/flutter_screenutil/blob/master/example/lib/main_zh.dart) 效果: diff --git a/README_PT.md b/README_PT.md index 7cc6c00..b4a4859 100644 --- a/README_PT.md +++ b/README_PT.md @@ -333,7 +333,7 @@ class _HomePageState extends State { ### Exemplo: -[Demonstração](/example/lib/main_zh.dart) +[Demonstração](https://github.com/OpenFlutter/flutter_screenutil/blob/master/example/lib/main_zh.dart) Efeito: diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index e2995ce..2ed0190 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -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" diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 221f822..15ea178 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -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 = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 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 = ""; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; @@ -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 = ""; }; @@ -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)", diff --git a/example/lib/main.dart b/example/lib/main.dart index a4d1b94..6a23ef5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -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 { child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ + TextButton(onPressed: null, child: Text('text')), Row( children: [ // Using Extensions diff --git a/example/lib/main_zh.dart b/example/lib/main_zh.dart index 2aeb7f9..4d08b4e 100644 --- a/example/lib/main_zh.dart +++ b/example/lib/main_zh.dart @@ -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'), );