{"id":636,"date":"2023-03-05T11:32:36","date_gmt":"2023-03-05T03:32:36","guid":{"rendered":"http:\/\/gjweb.top\/?p=636"},"modified":"2023-03-05T11:35:21","modified_gmt":"2023-03-05T03:35:21","slug":"07-%e6%89%8b%e6%9c%ba%e9%80%82%e9%85%8d","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=636","title":{"rendered":"07. \u624b\u673a\u9002\u914d"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u7b2c\u4e09\u65b9\u4f9d\u8d56 flutter_screenutil<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4f7f\u7528\">\u4f7f\u7528<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter_screenutil\/flutter_screenutil.dart';<br>void main() {<br> &nbsp;runApp(<br> &nbsp; &nbsp;ScreenUtilInit( \/\/ \u5d4c\u5957\u4e3b\u7ec4\u4ef6<br> &nbsp; &nbsp; &nbsp;designSize: const Size(1194, 834), \/\/ \u8bbe\u8ba1\u7a3f\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6<br> &nbsp; &nbsp; &nbsp;minTextAdapt: true,<br> &nbsp; &nbsp; &nbsp;splitScreenMode: true,<br> &nbsp; &nbsp; &nbsp;builder:(context,child){ <br> &nbsp; &nbsp; &nbsp; &nbsp;return GetMaterialApp(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;title: \"Application\",<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;defaultTransition:Transition.rightToLeft,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;initialRoute: AppPages.INITIAL,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;getPages: AppPages.routes,<br> &nbsp; &nbsp; &nbsp;  );<br> &nbsp; &nbsp;  }<br> &nbsp;  )<br>  );<br>}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u7ec4\u4ef6\u4e2d\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter_screenutil\/flutter_screenutil.dart';<br>\u200b<br>class MyScreenUtil {<br> &nbsp;static width(num val){return val.w;}<br> &nbsp;static height(num val){return val.h;}<br> &nbsp;static fontSize(num val){return val.sp;}<br> &nbsp;static radius(num val){return val.r;}<br> &nbsp;static getScreenWidth(){return 1.sw;}\/\/ \u83b7\u53d6\u5c4f\u5e55\u9ad8\u5ea6<br> &nbsp;static getScreenHeight(){return 1.sh;} \/\/ \u83b7\u53d6\u5c4f\u5e55\u5bbd\u5ea6<br> &nbsp;static getStatusBarHeight(){<br> &nbsp; &nbsp;return ScreenUtil().statusBarHeight;<br>  }<br>}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u7b2c\u4e09\u65b9\u4f9d\u8d56 flutter_screenutil \u4f7f\u7528 \u5728\u7ec4\u4ef6\u4e2d\u4f7f\u7528<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62],"tags":[],"class_list":["post-636","post","type-post","status-publish","format-standard","hentry","category-getx"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=636"}],"version-history":[{"count":1,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/636\/revisions"}],"predecessor-version":[{"id":637,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/636\/revisions\/637"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}