Showing
8 changed files
with
26 additions
and
8 deletions
1 | +# 5.0.2 | ||
2 | + | ||
3 | +- add "minTextAdapt" param , Font adaptation is based on the minimum value of width and height or only based on width(default) | ||
4 | +- update readme | ||
5 | + | ||
6 | +# 5.0.1+3 | ||
7 | + | ||
8 | +- fix .r | ||
9 | + | ||
1 | # 5.0.1+2 | 10 | # 5.0.1+2 |
2 | 11 | ||
3 | - Text adaptation no longer considers the height of the screen | 12 | - Text adaptation no longer considers the height of the screen |
@@ -79,6 +79,7 @@ class MyApp extends StatelessWidget { | @@ -79,6 +79,7 @@ class MyApp extends StatelessWidget { | ||
79 | //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp) | 79 | //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp) |
80 | return ScreenUtilInit( | 80 | return ScreenUtilInit( |
81 | designSize: Size(360, 690), | 81 | designSize: Size(360, 690), |
82 | + minTextAdapt: true, | ||
82 | builder: () => MaterialApp( | 83 | builder: () => MaterialApp( |
83 | ... | 84 | ... |
84 | theme: ThemeData( | 85 | theme: ThemeData( |
@@ -143,6 +144,7 @@ class _HomePageState extends State<HomePage> { | @@ -143,6 +144,7 @@ class _HomePageState extends State<HomePage> { | ||
143 | maxWidth: MediaQuery.of(context).size.width, | 144 | maxWidth: MediaQuery.of(context).size.width, |
144 | maxHeight: MediaQuery.of(context).size.height), | 145 | maxHeight: MediaQuery.of(context).size.height), |
145 | designSize: Size(360, 690), | 146 | designSize: Size(360, 690), |
147 | + minTextAdapt: true, | ||
146 | orientation: Orientation.portrait); | 148 | orientation: Orientation.portrait); |
147 | return Scaffold(); | 149 | return Scaffold(); |
148 | } | 150 | } |
@@ -60,6 +60,7 @@ class MyApp extends StatelessWidget { | @@ -60,6 +60,7 @@ class MyApp extends StatelessWidget { | ||
60 | //填入设计稿中设备的屏幕尺寸,单位dp | 60 | //填入设计稿中设备的屏幕尺寸,单位dp |
61 | return ScreenUtilInit( | 61 | return ScreenUtilInit( |
62 | designSize: Size(360, 690), | 62 | designSize: Size(360, 690), |
63 | + minTextAdapt: true, | ||
63 | builder: () => MaterialApp( | 64 | builder: () => MaterialApp( |
64 | debugShowCheckedModeBanner: false, | 65 | debugShowCheckedModeBanner: false, |
65 | title: 'Flutter_ScreenUtil', | 66 | title: 'Flutter_ScreenUtil', |
@@ -115,6 +116,7 @@ class _HomePageState extends State<HomePage> { | @@ -115,6 +116,7 @@ class _HomePageState extends State<HomePage> { | ||
115 | maxWidth: MediaQuery.of(context).size.width, | 116 | maxWidth: MediaQuery.of(context).size.width, |
116 | maxHeight: MediaQuery.of(context).size.height), | 117 | maxHeight: MediaQuery.of(context).size.height), |
117 | designSize: Size(360, 690), | 118 | designSize: Size(360, 690), |
119 | + minTextAdapt: true, | ||
118 | orientation: Orientation.portrait); | 120 | orientation: Orientation.portrait); |
119 | return Scaffold(); | 121 | return Scaffold(); |
120 | } | 122 | } |
@@ -56,6 +56,7 @@ class MyApp extends StatelessWidget { | @@ -56,6 +56,7 @@ class MyApp extends StatelessWidget { | ||
56 | //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp) | 56 | //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp) |
57 | return ScreenUtilInit( | 57 | return ScreenUtilInit( |
58 | designSize: Size(360, 690), | 58 | designSize: Size(360, 690), |
59 | + minTextAdapt: true, | ||
59 | builder: () => MaterialApp( | 60 | builder: () => MaterialApp( |
60 | ... | 61 | ... |
61 | theme: ThemeData( | 62 | theme: ThemeData( |
@@ -9,6 +9,7 @@ class MyApp extends StatelessWidget { | @@ -9,6 +9,7 @@ class MyApp extends StatelessWidget { | ||
9 | //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) | 9 | //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) |
10 | return ScreenUtilInit( | 10 | return ScreenUtilInit( |
11 | designSize: Size(360, 690), | 11 | designSize: Size(360, 690), |
12 | + minTextAdapt: true, | ||
12 | splitScreenMode: true, | 13 | splitScreenMode: true, |
13 | builder: () => MaterialApp( | 14 | builder: () => MaterialApp( |
14 | debugShowCheckedModeBanner: false, | 15 | debugShowCheckedModeBanner: false, |
@@ -21,6 +21,7 @@ class ScreenUtil { | @@ -21,6 +21,7 @@ class ScreenUtil { | ||
21 | late double _screenHeight; | 21 | late double _screenHeight; |
22 | late double _statusBarHeight; | 22 | late double _statusBarHeight; |
23 | late double _bottomBarHeight; | 23 | late double _bottomBarHeight; |
24 | + late bool _minTextAdapt; | ||
24 | 25 | ||
25 | ScreenUtil._(); | 26 | ScreenUtil._(); |
26 | 27 | ||
@@ -33,14 +34,14 @@ class ScreenUtil { | @@ -33,14 +34,14 @@ class ScreenUtil { | ||
33 | Orientation orientation = Orientation.portrait, | 34 | Orientation orientation = Orientation.portrait, |
34 | Size designSize = defaultSize, | 35 | Size designSize = defaultSize, |
35 | bool splitScreenMode = false, | 36 | bool splitScreenMode = false, |
37 | + bool minTextAdapt = false, | ||
36 | }) { | 38 | }) { |
37 | _instance = ScreenUtil._() | 39 | _instance = ScreenUtil._() |
38 | ..uiSize = designSize | 40 | ..uiSize = designSize |
41 | + .._minTextAdapt = minTextAdapt | ||
39 | .._orientation = orientation | 42 | .._orientation = orientation |
40 | .._screenWidth = constraints.maxWidth | 43 | .._screenWidth = constraints.maxWidth |
41 | - .._screenHeight = splitScreenMode | ||
42 | - ? max(constraints.maxHeight, 700) | ||
43 | - : constraints.maxHeight; | 44 | + .._screenHeight = splitScreenMode ? max(constraints.maxHeight, 700) : constraints.maxHeight; |
44 | 45 | ||
45 | var window = WidgetsBinding.instance?.window ?? ui.window; | 46 | var window = WidgetsBinding.instance?.window ?? ui.window; |
46 | _instance._pixelRatio = window.devicePixelRatio; | 47 | _instance._pixelRatio = window.devicePixelRatio; |
@@ -84,7 +85,7 @@ class ScreenUtil { | @@ -84,7 +85,7 @@ class ScreenUtil { | ||
84 | /// /// The ratio of actual height to UI design | 85 | /// /// The ratio of actual height to UI design |
85 | double get scaleHeight => _screenHeight / uiSize.height; | 86 | double get scaleHeight => _screenHeight / uiSize.height; |
86 | 87 | ||
87 | - double get scaleText => scaleWidth; | 88 | + double get scaleText => _minTextAdapt ? min(scaleWidth, scaleHeight) : scaleWidth; |
88 | 89 | ||
89 | /// 根据UI设计的设备宽度适配 | 90 | /// 根据UI设计的设备宽度适配 |
90 | /// 高度也可以根据这个来做适配可以保证不变形,比如你想要一个正方形的时候. | 91 | /// 高度也可以根据这个来做适配可以保证不变形,比如你想要一个正方形的时候. |
@@ -6,11 +6,13 @@ class ScreenUtilInit extends StatelessWidget { | @@ -6,11 +6,13 @@ class ScreenUtilInit extends StatelessWidget { | ||
6 | required this.builder, | 6 | required this.builder, |
7 | this.designSize = ScreenUtil.defaultSize, | 7 | this.designSize = ScreenUtil.defaultSize, |
8 | this.splitScreenMode = true, | 8 | this.splitScreenMode = true, |
9 | + this.minTextAdapt = false, | ||
9 | Key? key, | 10 | Key? key, |
10 | }) : super(key: key); | 11 | }) : super(key: key); |
11 | 12 | ||
12 | final Widget Function() builder; | 13 | final Widget Function() builder; |
13 | final bool splitScreenMode; | 14 | final bool splitScreenMode; |
15 | + final bool minTextAdapt; | ||
14 | 16 | ||
15 | /// The [Size] of the device in the design draft, in dp | 17 | /// The [Size] of the device in the design draft, in dp |
16 | final Size designSize; | 18 | final Size designSize; |
@@ -19,14 +21,14 @@ class ScreenUtilInit extends StatelessWidget { | @@ -19,14 +21,14 @@ class ScreenUtilInit extends StatelessWidget { | ||
19 | Widget build(BuildContext context) { | 21 | Widget build(BuildContext context) { |
20 | return LayoutBuilder(builder: (_, BoxConstraints constraints) { | 22 | return LayoutBuilder(builder: (_, BoxConstraints constraints) { |
21 | if (constraints.maxWidth != 0) { | 23 | if (constraints.maxWidth != 0) { |
22 | - final Orientation orientation = | ||
23 | - constraints.maxWidth > constraints.maxHeight | 24 | + final Orientation orientation = constraints.maxWidth > constraints.maxHeight |
24 | ? Orientation.landscape | 25 | ? Orientation.landscape |
25 | : Orientation.portrait; | 26 | : Orientation.portrait; |
26 | ScreenUtil.init(constraints, | 27 | ScreenUtil.init(constraints, |
27 | orientation: orientation, | 28 | orientation: orientation, |
28 | designSize: designSize, | 29 | designSize: designSize, |
29 | - splitScreenMode: splitScreenMode); | 30 | + splitScreenMode: splitScreenMode, |
31 | + minTextAdapt: minTextAdapt); | ||
30 | return builder(); | 32 | return builder(); |
31 | } | 33 | } |
32 | return Container(); | 34 | return Container(); |
1 | name: flutter_screenutil | 1 | name: flutter_screenutil |
2 | description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models | 2 | description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models |
3 | -version: 5.0.1+2 | 3 | +version: 5.0.2 |
4 | homepage: https://github.com/OpenFlutter/flutter_screenutil | 4 | homepage: https://github.com/OpenFlutter/flutter_screenutil |
5 | 5 | ||
6 | environment: | 6 | environment: |
-
Please register or login to post a comment