Showing
6 changed files
with
53 additions
and
10 deletions
| @@ -49,15 +49,36 @@ class MyApp extends StatelessWidget { | @@ -49,15 +49,36 @@ class MyApp extends StatelessWidget { | ||
| 49 | //Set the fit size (fill in the screen size of the device in the design,in dp) | 49 | //Set the fit size (fill in the screen size of the device in the design,in dp) |
| 50 | return ScreenUtilInit( | 50 | return ScreenUtilInit( |
| 51 | designSize: Size(360, 690), | 51 | designSize: Size(360, 690), |
| 52 | - allowFontScaling: false, | ||
| 53 | builder: () => MaterialApp( | 52 | builder: () => MaterialApp( |
| 54 | ... | 53 | ... |
| 54 | + theme: ThemeData( | ||
| 55 | + primarySwatch: Colors.blue, | ||
| 56 | + textTheme: TextTheme( | ||
| 57 | + //To support the following, you need to use the first initialization method | ||
| 58 | + button: TextStyle(fontSize: 45.sp) | ||
| 59 | + ), | ||
| 60 | + ), | ||
| 55 | ), | 61 | ), |
| 56 | ); | 62 | ); |
| 57 | } | 63 | } |
| 58 | } | 64 | } |
| 65 | + | ||
| 59 | ``` | 66 | ``` |
| 60 | -The second way:Does not support the use of font adaptation in the App | 67 | +The second way:Does not support font adaptation in the textTheme of MaterialApp's theme. |
| 68 | + | ||
| 69 | +not support this: | ||
| 70 | +```dart | ||
| 71 | +MaterialApp( | ||
| 72 | + ... | ||
| 73 | + theme: ThemeData( | ||
| 74 | + textTheme: TextTheme( | ||
| 75 | + //To support the following, you need to use the first initialization method | ||
| 76 | + button: TextStyle(fontSize: 45.sp) | ||
| 77 | + ), | ||
| 78 | + ), | ||
| 79 | +) | ||
| 80 | +``` | ||
| 81 | + | ||
| 61 | ```dart | 82 | ```dart |
| 62 | class MyApp extends StatelessWidget { | 83 | class MyApp extends StatelessWidget { |
| 63 | @override | 84 | @override |
| @@ -55,20 +55,24 @@ class MyApp extends StatelessWidget { | @@ -55,20 +55,24 @@ class MyApp extends StatelessWidget { | ||
| 55 | //填入设计稿中设备的屏幕尺寸,单位dp | 55 | //填入设计稿中设备的屏幕尺寸,单位dp |
| 56 | return ScreenUtilInit( | 56 | return ScreenUtilInit( |
| 57 | designSize: Size(360, 690), | 57 | designSize: Size(360, 690), |
| 58 | - allowFontScaling: false, | ||
| 59 | builder: () => MaterialApp( | 58 | builder: () => MaterialApp( |
| 60 | debugShowCheckedModeBanner: false, | 59 | debugShowCheckedModeBanner: false, |
| 61 | title: 'Flutter_ScreenUtil', | 60 | title: 'Flutter_ScreenUtil', |
| 62 | theme: ThemeData( | 61 | theme: ThemeData( |
| 63 | - primarySwatch: Colors.blue, | ||
| 64 | - ), | 62 | + primarySwatch: Colors.blue, |
| 63 | + //要支持下面这个需要使用第一种初始化方式 | ||
| 64 | + textTheme: TextTheme( | ||
| 65 | + button: TextStyle(fontSize: 45.sp) | ||
| 66 | + ), | ||
| 67 | + ), | ||
| 65 | home: HomePage(title: 'FlutterScreenUtil Demo'), | 68 | home: HomePage(title: 'FlutterScreenUtil Demo'), |
| 66 | ), | 69 | ), |
| 67 | ); | 70 | ); |
| 68 | } | 71 | } |
| 69 | } | 72 | } |
| 70 | ``` | 73 | ``` |
| 71 | -方式二: 不支持在App中使用字体适配 | 74 | + |
| 75 | +方式二: 不支持在MaterialApp的theme的textTheme中使用字体适配 | ||
| 72 | ``` | 76 | ``` |
| 73 | class MyApp extends StatelessWidget { | 77 | class MyApp extends StatelessWidget { |
| 74 | @override | 78 | @override |
| @@ -55,12 +55,20 @@ class MyApp extends StatelessWidget { | @@ -55,12 +55,20 @@ class MyApp extends StatelessWidget { | ||
| 55 | designSize: Size(360, 690), | 55 | designSize: Size(360, 690), |
| 56 | builder: () => MaterialApp( | 56 | builder: () => MaterialApp( |
| 57 | ... | 57 | ... |
| 58 | + theme: ThemeData( | ||
| 59 | + primarySwatch: Colors.blue, | ||
| 60 | + //To support the following, you need to use the first initialization method | ||
| 61 | + textTheme: TextTheme( | ||
| 62 | + button: TextStyle(fontSize: 45.sp) | ||
| 63 | + ), | ||
| 64 | + ), | ||
| 58 | ), | 65 | ), |
| 59 | ); | 66 | ); |
| 60 | } | 67 | } |
| 61 | } | 68 | } |
| 62 | ``` | 69 | ``` |
| 63 | -The second way:Does not support the use of font adaptation in the App | 70 | + |
| 71 | +The second way:Does not support font adaptation in the textTheme of MaterialApp's theme. | ||
| 64 | ``` | 72 | ``` |
| 65 | class MyApp extends StatelessWidget { | 73 | class MyApp extends StatelessWidget { |
| 66 | @override | 74 | @override |
| @@ -5,9 +5,11 @@ export "FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_s | @@ -5,9 +5,11 @@ export "FLUTTER_APPLICATION_PATH=/Users/lizhuoyuan/Development/Project/flutter_s | ||
| 5 | export "FLUTTER_TARGET=lib/main.dart" | 5 | export "FLUTTER_TARGET=lib/main.dart" |
| 6 | export "FLUTTER_BUILD_DIR=build" | 6 | export "FLUTTER_BUILD_DIR=build" |
| 7 | export "SYMROOT=${SOURCE_ROOT}/../build/ios" | 7 | export "SYMROOT=${SOURCE_ROOT}/../build/ios" |
| 8 | +export "OTHER_LDFLAGS=$(inherited) -framework Flutter" | ||
| 9 | +export "FLUTTER_FRAMEWORK_DIR=/Users/lizhuoyuan/Development/flutter/bin/cache/artifacts/engine/ios-release" | ||
| 8 | export "FLUTTER_BUILD_NAME=1.0.0" | 10 | export "FLUTTER_BUILD_NAME=1.0.0" |
| 9 | export "FLUTTER_BUILD_NUMBER=1" | 11 | export "FLUTTER_BUILD_NUMBER=1" |
| 10 | export "DART_OBFUSCATION=false" | 12 | export "DART_OBFUSCATION=false" |
| 11 | export "TRACK_WIDGET_CREATION=false" | 13 | export "TRACK_WIDGET_CREATION=false" |
| 12 | -export "TREE_SHAKE_ICONS=false" | 14 | +export "TREE_SHAKE_ICONS=true" |
| 13 | export "PACKAGE_CONFIG=.packages" | 15 | export "PACKAGE_CONFIG=.packages" |
| @@ -144,6 +144,8 @@ | @@ -144,6 +144,8 @@ | ||
| 144 | TargetAttributes = { | 144 | TargetAttributes = { |
| 145 | 97C146ED1CF9000F007C117D = { | 145 | 97C146ED1CF9000F007C117D = { |
| 146 | CreatedOnToolsVersion = 7.3.1; | 146 | CreatedOnToolsVersion = 7.3.1; |
| 147 | + DevelopmentTeam = HW92UC978N; | ||
| 148 | + ProvisioningStyle = Automatic; | ||
| 147 | }; | 149 | }; |
| 148 | }; | 150 | }; |
| 149 | }; | 151 | }; |
| @@ -350,8 +352,10 @@ | @@ -350,8 +352,10 @@ | ||
| 350 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; | 352 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; |
| 351 | buildSettings = { | 353 | buildSettings = { |
| 352 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | 354 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; |
| 355 | + CODE_SIGN_IDENTITY = "Apple Development"; | ||
| 356 | + CODE_SIGN_STYLE = Automatic; | ||
| 353 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | 357 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; |
| 354 | - DEVELOPMENT_TEAM = ""; | 358 | + DEVELOPMENT_TEAM = HW92UC978N; |
| 355 | ENABLE_BITCODE = NO; | 359 | ENABLE_BITCODE = NO; |
| 356 | FRAMEWORK_SEARCH_PATHS = ( | 360 | FRAMEWORK_SEARCH_PATHS = ( |
| 357 | "$(inherited)", | 361 | "$(inherited)", |
| @@ -365,6 +369,7 @@ | @@ -365,6 +369,7 @@ | ||
| 365 | ); | 369 | ); |
| 366 | PRODUCT_BUNDLE_IDENTIFIER = li.zhuoyuan.example; | 370 | PRODUCT_BUNDLE_IDENTIFIER = li.zhuoyuan.example; |
| 367 | PRODUCT_NAME = "$(TARGET_NAME)"; | 371 | PRODUCT_NAME = "$(TARGET_NAME)"; |
| 372 | + PROVISIONING_PROFILE_SPECIFIER = ""; | ||
| 368 | VERSIONING_SYSTEM = "apple-generic"; | 373 | VERSIONING_SYSTEM = "apple-generic"; |
| 369 | }; | 374 | }; |
| 370 | name = Debug; | 375 | name = Debug; |
| @@ -375,7 +380,7 @@ | @@ -375,7 +380,7 @@ | ||
| 375 | buildSettings = { | 380 | buildSettings = { |
| 376 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | 381 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; |
| 377 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | 382 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; |
| 378 | - DEVELOPMENT_TEAM = E4T4EJGC8Z; | 383 | + DEVELOPMENT_TEAM = HW92UC978N; |
| 379 | ENABLE_BITCODE = NO; | 384 | ENABLE_BITCODE = NO; |
| 380 | FRAMEWORK_SEARCH_PATHS = ( | 385 | FRAMEWORK_SEARCH_PATHS = ( |
| 381 | "$(inherited)", | 386 | "$(inherited)", |
| @@ -14,6 +14,9 @@ class MyApp extends StatelessWidget { | @@ -14,6 +14,9 @@ class MyApp extends StatelessWidget { | ||
| 14 | title: 'Flutter_ScreenUtil', | 14 | title: 'Flutter_ScreenUtil', |
| 15 | theme: ThemeData( | 15 | theme: ThemeData( |
| 16 | primarySwatch: Colors.blue, | 16 | primarySwatch: Colors.blue, |
| 17 | + textTheme: TextTheme( | ||
| 18 | + button: TextStyle(fontSize: 45.sp) | ||
| 19 | + ), | ||
| 17 | ), | 20 | ), |
| 18 | builder: (context, widget) { | 21 | builder: (context, widget) { |
| 19 | return MediaQuery( | 22 | return MediaQuery( |
-
Please register or login to post a comment