当前位置: 首页 > 后端技术 > Python

Flutter适配不同尺寸的移动端和web端

时间:2023-03-26 18:01:31 Python

使用的库是开源库,可以适配不同的屏幕尺寸。如何使用responsive_builder1.pubspec.yaml导入库responsive_builder:^0.3.02。代码引用import'package:responsive_builder/responsive_builder.dart';3.和使用普通控件一样,使用下面的代码:);}if(sizingInformation.deviceScreenType==DeviceScreenType.tablet){returnContainer(color:Colors.red,child:Text("tablet"),);}if(sizingInformation.deviceScreenType==DeviceScreenType.watch){返回容器(颜色:颜色。黄色,孩子:文本(“手表”),);}returnContainer(color:Colors.green,child:Text("mobile"),);},),上面的代码可以返回不同的Container。其他参考文章