zhuoyuan

5.0.2

fix #306
# 5.0.2
- add "minTextAdapt" param , Font adaptation is based on the minimum value of width and height or only based on width(default)
- update readme
# 5.0.1+3
- fix .r
# 5.0.1+2
- Text adaptation no longer considers the height of the screen
... ...
... ... @@ -79,6 +79,7 @@ class MyApp extends StatelessWidget {
//Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp)
return ScreenUtilInit(
designSize: Size(360, 690),
minTextAdapt: true,
builder: () => MaterialApp(
...
theme: ThemeData(
... ... @@ -143,6 +144,7 @@ class _HomePageState extends State<HomePage> {
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
minTextAdapt: true,
orientation: Orientation.portrait);
return Scaffold();
}
... ...
... ... @@ -60,6 +60,7 @@ class MyApp extends StatelessWidget {
//填入设计稿中设备的屏幕尺寸,单位dp
return ScreenUtilInit(
designSize: Size(360, 690),
minTextAdapt: true,
builder: () => MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter_ScreenUtil',
... ... @@ -115,6 +116,7 @@ class _HomePageState extends State<HomePage> {
maxWidth: MediaQuery.of(context).size.width,
maxHeight: MediaQuery.of(context).size.height),
designSize: Size(360, 690),
minTextAdapt: true,
orientation: Orientation.portrait);
return Scaffold();
}
... ...
... ... @@ -56,6 +56,7 @@ class MyApp extends StatelessWidget {
//Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp)
return ScreenUtilInit(
designSize: Size(360, 690),
minTextAdapt: true,
builder: () => MaterialApp(
...
theme: ThemeData(
... ...
... ... @@ -9,6 +9,7 @@ class MyApp extends StatelessWidget {
//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)
return ScreenUtilInit(
designSize: Size(360, 690),
minTextAdapt: true,
splitScreenMode: true,
builder: () => MaterialApp(
debugShowCheckedModeBanner: false,
... ...
... ... @@ -21,6 +21,7 @@ class ScreenUtil {
late double _screenHeight;
late double _statusBarHeight;
late double _bottomBarHeight;
late bool _minTextAdapt;
ScreenUtil._();
... ... @@ -33,14 +34,14 @@ class ScreenUtil {
Orientation orientation = Orientation.portrait,
Size designSize = defaultSize,
bool splitScreenMode = false,
bool minTextAdapt = false,
}) {
_instance = ScreenUtil._()
..uiSize = designSize
.._minTextAdapt = minTextAdapt
.._orientation = orientation
.._screenWidth = constraints.maxWidth
.._screenHeight = splitScreenMode
? max(constraints.maxHeight, 700)
: constraints.maxHeight;
.._screenHeight = splitScreenMode ? max(constraints.maxHeight, 700) : constraints.maxHeight;
var window = WidgetsBinding.instance?.window ?? ui.window;
_instance._pixelRatio = window.devicePixelRatio;
... ... @@ -84,7 +85,7 @@ class ScreenUtil {
/// /// The ratio of actual height to UI design
double get scaleHeight => _screenHeight / uiSize.height;
double get scaleText => scaleWidth;
double get scaleText => _minTextAdapt ? min(scaleWidth, scaleHeight) : scaleWidth;
/// 根据UI设计的设备宽度适配
/// 高度也可以根据这个来做适配可以保证不变形,比如你想要一个正方形的时候.
... ...
... ... @@ -6,11 +6,13 @@ class ScreenUtilInit extends StatelessWidget {
required this.builder,
this.designSize = ScreenUtil.defaultSize,
this.splitScreenMode = true,
this.minTextAdapt = false,
Key? key,
}) : super(key: key);
final Widget Function() builder;
final bool splitScreenMode;
final bool minTextAdapt;
/// The [Size] of the device in the design draft, in dp
final Size designSize;
... ... @@ -19,14 +21,14 @@ class ScreenUtilInit extends StatelessWidget {
Widget build(BuildContext context) {
return LayoutBuilder(builder: (_, BoxConstraints constraints) {
if (constraints.maxWidth != 0) {
final Orientation orientation =
constraints.maxWidth > constraints.maxHeight
? Orientation.landscape
: Orientation.portrait;
final Orientation orientation = constraints.maxWidth > constraints.maxHeight
? Orientation.landscape
: Orientation.portrait;
ScreenUtil.init(constraints,
orientation: orientation,
designSize: designSize,
splitScreenMode: splitScreenMode);
splitScreenMode: splitScreenMode,
minTextAdapt: minTextAdapt);
return builder();
}
return Container();
... ...
name: flutter_screenutil
description: A flutter plugin for adapting screen and font size.Guaranteed to look good on different models
version: 5.0.1+2
version: 5.0.2
homepage: https://github.com/OpenFlutter/flutter_screenutil
environment:
... ...