简体   繁体   English

如何在 flutter 中使用 Transform.scale?

[英]How to use Transform.scale in flutter?

I want to use Transform.scale to manage sizes such as text size, icon size, etc, to make it flexible base on platform resolution such as mobile tablet or IPad.我想使用Transform.scale来管理文本大小、图标大小等大小,以使其灵活地基于移动平板电脑或 iPad 等平台分辨率。 However, I do not know what is the exact scale value for mobile or ipad.但是,我不知道手机或 ipad 的确切比例值是多少。

This is my code:这是我的代码:

Transform.scale(
            scale: 1,  // here is the scale value
            child: Container(
              height: 1000,
              width: 500,
              color: const Color(0xFFE8581C),
              child: const Icon(
                Icons.home,
                size: 100,
              ),
            ),
          ),

How can I adapt this to use flexible styles?我如何调整它以使用灵活的样式?

Well, You have to research on what constraints define the device type.好吧,您必须研究哪些约束定义了设备类型。 mostly height and width are used to define what kind of device we are using.高度和宽度主要用于定义我们使用的设备类型。 it also happens that there are some special type of devices like foldable phones and others...也有一些特殊类型的设备,如可折叠手机和其他设备......

if we consider android phone google have made 3 categories of device types: Compact(normal phones), Medium(foldable, mini tablets), Expanded (large screen tablets) as a specific values of height and width can be found out using media query and render accordingly如果我们考虑 android 手机,google 已经将设备类型分为 3 类:Compact(普通手机)、Medium(可折叠、迷你平板电脑)、Expanded(大屏幕平板电脑),因为可以使用媒体查询找到特定的高度和宽度值,并且相应地渲染

find more info about android layouts here Responsive layouts by google develoeprs在此处找到有关 android 布局的更多信息Responsive layouts by google develoeprs

a good starting point for you is to learn about responsive layouts in flutter using media query一个很好的起点是使用 媒体查询了解 flutter 中的响应式布局

i will attach a good tutorial for you to get started on flutter ui responsiveness check out我将附上一个很好的教程,供您开始了解 Flutter UI 响应性,请查看

Adaptive vs Responsive Design with flutter - flutterYT Flutter 的自适应与响应式设计 - flutterYT

Responsive UI with flutter - Mitch Koko带有 flutter 的响应式 UI - Mitch Koko

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM