Showing
3 changed files
with
10 additions
and
13 deletions
| @@ -46,7 +46,7 @@ void main() => runApp(MyApp()); | @@ -46,7 +46,7 @@ void main() => runApp(MyApp()); | ||
| 46 | class MyApp extends StatelessWidget { | 46 | class MyApp extends StatelessWidget { |
| 47 | @override | 47 | @override |
| 48 | Widget build(BuildContext context) { | 48 | Widget build(BuildContext context) { |
| 49 | - //Set the fit size (fill in the screen size of the device in the design,in dp) | 49 | + //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp) |
| 50 | return ScreenUtilInit( | 50 | return ScreenUtilInit( |
| 51 | designSize: Size(360, 690), | 51 | designSize: Size(360, 690), |
| 52 | builder: () => MaterialApp( | 52 | builder: () => MaterialApp( |
| @@ -50,7 +50,7 @@ void main() => runApp(MyApp()); | @@ -50,7 +50,7 @@ void main() => runApp(MyApp()); | ||
| 50 | class MyApp extends StatelessWidget { | 50 | class MyApp extends StatelessWidget { |
| 51 | @override | 51 | @override |
| 52 | Widget build(BuildContext context) { | 52 | Widget build(BuildContext context) { |
| 53 | - //Set the fit size (fill in the screen size of the device in the design,in dp) | 53 | + //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp) |
| 54 | return ScreenUtilInit( | 54 | return ScreenUtilInit( |
| 55 | designSize: Size(360, 690), | 55 | designSize: Size(360, 690), |
| 56 | builder: () => MaterialApp( | 56 | builder: () => MaterialApp( |
| @@ -96,7 +96,7 @@ class HomePage extends StatefulWidget { | @@ -96,7 +96,7 @@ class HomePage extends StatefulWidget { | ||
| 96 | class _HomePageState extends State<HomePage> { | 96 | class _HomePageState extends State<HomePage> { |
| 97 | @override | 97 | @override |
| 98 | Widget build(BuildContext context) { | 98 | Widget build(BuildContext context) { |
| 99 | - //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 360*690(dp) | 99 | + //Set the fit size (Find your UI design, look at the dimensions of the device screen and fill it in,unit in dp) |
| 100 | ScreenUtil.init( | 100 | ScreenUtil.init( |
| 101 | BoxConstraints( | 101 | BoxConstraints( |
| 102 | maxWidth: MediaQuery.of(context).size.width, | 102 | maxWidth: MediaQuery.of(context).size.width, |
| @@ -31,11 +31,11 @@ class _HomePageState extends State<HomePage> { | @@ -31,11 +31,11 @@ class _HomePageState extends State<HomePage> { | ||
| 31 | Widget build(BuildContext context) { | 31 | Widget build(BuildContext context) { |
| 32 | //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 360*690 | 32 | //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 360*690 |
| 33 | ScreenUtil.init( | 33 | ScreenUtil.init( |
| 34 | - BoxConstraints( | ||
| 35 | - maxWidth: MediaQuery.of(context).size.width, | ||
| 36 | - maxHeight: MediaQuery.of(context).size.height), | ||
| 37 | - designSize: Size(360, 690), | ||
| 38 | - orientation: Orientation.portrait); | 34 | + BoxConstraints( |
| 35 | + maxWidth: MediaQuery.of(context).size.width, | ||
| 36 | + maxHeight: MediaQuery.of(context).size.height), | ||
| 37 | + designSize: Size(360, 690), | ||
| 38 | + ); | ||
| 39 | printScreenInformation(); | 39 | printScreenInformation(); |
| 40 | return Scaffold( | 40 | return Scaffold( |
| 41 | appBar: AppBar( | 41 | appBar: AppBar( |
| @@ -66,9 +66,7 @@ class _HomePageState extends State<HomePage> { | @@ -66,9 +66,7 @@ class _HomePageState extends State<HomePage> { | ||
| 66 | child: Text( | 66 | child: Text( |
| 67 | '我的设计稿宽度: 180dp \n' | 67 | '我的设计稿宽度: 180dp \n' |
| 68 | '我的设计稿高度: 200dp', | 68 | '我的设计稿高度: 200dp', |
| 69 | - style: TextStyle( | ||
| 70 | - color: Colors.white, | ||
| 71 | - fontSize: ScreenUtil().setSp(12))), | 69 | + style: TextStyle(color: Colors.white, fontSize: ScreenUtil().setSp(12))), |
| 72 | ), | 70 | ), |
| 73 | ], | 71 | ], |
| 74 | ), | 72 | ), |
| @@ -136,8 +134,7 @@ class _HomePageState extends State<HomePage> { | @@ -136,8 +134,7 @@ class _HomePageState extends State<HomePage> { | ||
| 136 | print('状态栏高度:${ScreenUtil().statusBarHeight}dp'); | 134 | print('状态栏高度:${ScreenUtil().statusBarHeight}dp'); |
| 137 | print('实际宽度和字体(dp)与设计稿(dp)的比例:${ScreenUtil().scaleWidth}'); | 135 | print('实际宽度和字体(dp)与设计稿(dp)的比例:${ScreenUtil().scaleWidth}'); |
| 138 | print('实际高度(dp)与设计稿(dp)的比例:${ScreenUtil().scaleHeight}'); | 136 | print('实际高度(dp)与设计稿(dp)的比例:${ScreenUtil().scaleHeight}'); |
| 139 | - print( | ||
| 140 | - '高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight}'); | 137 | + print('高度相对于设计稿放大的比例:${ScreenUtil().scaleHeight}'); |
| 141 | print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}'); | 138 | print('系统的字体缩放比例:${ScreenUtil().textScaleFactor}'); |
| 142 | print('屏幕宽度的0.5:${0.5.sw}dp'); | 139 | print('屏幕宽度的0.5:${0.5.sw}dp'); |
| 143 | print('屏幕高度的0.5:${0.5.sh}dp'); | 140 | print('屏幕高度的0.5:${0.5.sh}dp'); |
-
Please register or login to post a comment