初始化以后就可以使用flutter_screenutil提供的方法获取到适配后的数值进行使用了。 可通过如下 api 获取宽高以及字体的适配数值: ScreenUtil().setWidth(540)//根据屏幕宽度适配尺寸ScreenUtil().setHeight(200)//根据屏幕高度适配尺寸(一般根据宽度适配即可)ScreenUtil().radius(200)//根据宽度或高度中的较小者进行调...
插件地址 : https://pub.dev/packages/flutter_screenutil 插件使用案例 : https://pub.dev/packages/flutter_screenutil/example 插件安装文档 : https://pub.dev/packages/flutter_screenutil/install GitHub 地址: https://github.com/OpenFlutter/flutter_screenutil 中文文档 ( 强烈推荐看这个文档 ) : https:/...
一,flutter_screenutil库的地址: https://pub.dev/packages/flutter_screenutil 代码地址: https://github.com/OpenFlutter/flutter_screenutil 说明:刘宏缔的架构森林是一个专注架构的博客, 网站:https://blog.imgtouch.com 原文:https://blog.imgtouch.com/index.php/2023/06/04/flutter-shi-pei-ping-mu-flut...
根据屏幕宽度适配 width: ScreenUtil().setWidth(540), 根据屏幕高度适配 height: ScreenUtil().setHeight(200), Container( padding: EdgeInsets.all(ScreenUtil().setWidth(10)), width: ScreenUtil().setWidth(375), height: ScreenUtil().setHeight(200), color: Colors.red, child: Text( '我的宽度:${...
本来以为Flutter的屏幕适配会挺完美之前就没关心过,为了解决设计图和需要的数字之间转换问题,所以才加上了此插件官方文档地址 flutter_screenutil[http...
import'package:flutter_screenutil/flutter_screenutil.dart'; voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget{@override Widgetbuild(BuildContext context){//填入设计稿中设备的屏幕尺寸,单位dpreturnScreenUtilInit(designSize:constSize(360,690),minTextAdapt:true,splitScreenMode:true,builder:(contex...
voidmain(){WidgetsFlutterBinding.ensureInitialized();//设置适配尺寸 (填入设计稿中设备的屏幕尺寸) 此处假如设计稿是按iPhone6的尺寸设计的(iPhone6 750*1334)ScreenUtil.init(context,designSize:Size(750,1334),allowFontScaling:false);runApp(MyApp());}//默认 width : 1080px , height:1920px , allowFont...
文章目录一、推荐使用 flutter_screenutil 插件二、flutter_screenutil 插件使用1、导入 flutter_screenutil 插件依赖2、 flutter_screenutil 初始化3、 flutter_screenutil 使用 API4、 设置字体5、 设置...
Flutter中的`flutter_screenutil`包是一个用于处理屏幕适配的工具,它可以帮助开发者根据不同的屏幕尺寸来设置UI元素的高度和宽度。如果你遇到了无法使用`flutter_scree...
ScreenUtil.getInstance().setHeight(double height); //获取宽度 ScreenUtil.getInstance().getWidth(); //获取高度 ScreenUtil.getInstance().getHeight(); 2、字体大小转换 //设置字体大小 ScreenUtil.getInstance().setTextSize(double size); //获取字体大小 ScreenUtil.getInstance().getTextSize(); 3、其他功能...