-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
84 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
<!-- | ||
* @Author: [email protected] | ||
* @Date: 2018-10-16 19:43:03 | ||
* @LastEditors: [email protected] | ||
* @LastEditTime: 2020年6月20日 11:20:02 | ||
* @Description: Update log | ||
--> | ||
# 4.0.2 | ||
- add r(),adapt according to the smaller of width or height | ||
|
||
# 4.0.1 | ||
- Modify the initialization unit to dp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
* email: [email protected] | ||
*/ | ||
|
||
import 'dart:math'; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
class ScreenUtil { | ||
|
@@ -84,7 +86,7 @@ class ScreenUtil { | |
/// /// The ratio of actual height to UI design | ||
double get scaleHeight => _screenHeight / uiSize.height; | ||
|
||
double get scaleText => scaleWidth; | ||
double get scaleText => min(scaleWidth, scaleHeight); | ||
|
||
/// 根据UI设计的设备宽度适配 | ||
/// 高度也可以根据这个来做适配可以保证不变形,比如你先要一个正方形的时候. | ||
|
@@ -103,14 +105,22 @@ class ScreenUtil { | |
/// does not match the current style effect, or if there is a difference in shape. | ||
double setHeight(num height) => height * scaleHeight; | ||
|
||
///Adapt according to the smaller of width or height | ||
num radius(num r) => r * scaleText; | ||
|
||
///字体大小适配方法 | ||
///- [fontSize] UI设计上字体的大小,单位px. | ||
///Font size adaptation method | ||
///- [fontSize] The size of the font on the UI design, in px. | ||
///- [allowFontScaling] | ||
double setSp(num fontSize, {bool allowFontScalingSelf}) => allowFontScalingSelf == null | ||
? (allowFontScaling ? (fontSize * scaleText) : (fontSize * scaleText / _textScaleFactor)) | ||
: (allowFontScalingSelf ? (fontSize * scaleText) : (fontSize * scaleText / _textScaleFactor)); | ||
double setSp(num fontSize, {bool allowFontScalingSelf}) => | ||
allowFontScalingSelf == null | ||
? (allowFontScaling | ||
? (fontSize * scaleText) | ||
: (fontSize * scaleText / _textScaleFactor)) | ||
: (allowFontScalingSelf | ||
? (fontSize * scaleText) | ||
: (fontSize * scaleText / _textScaleFactor)); | ||
} | ||
|
||
enum UnitType { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters