简体   繁体   English

Flutter - 如何更改 CheckboxListTile 大小?

[英]Flutter - how to change CheckboxListTile size?

How can I change only the checkbox icon size on a CheckboxListTile?如何仅更改 CheckboxListTile 上的复选框图标大小? For a Checkbox widget I was able to change its size using Transform.scale, but on the CheckboxListTile I couldn't manipulate the checkbox icon.对于 Checkbox 小部件,我可以使用 Transform.scale 更改其大小,但在 CheckboxListTile 上我无法操作复选框图标。 On a tablet screen the size is too small as you can see in the image.如图所示,在平板电脑屏幕上,尺寸太小了。

平板电脑和手机

No worries., Its better then use Transform.scale().不用担心,最好使用 Transform.scale()。 It would help you to manage the size with scaling functionality..它将帮助您通过缩放功能管理大小..

*** Code below *** ***下面的代码***

Row(
          children: [
            Transform.scale(
              scale: 1.3,
              child: Checkbox(value: mail, onChanged: (value) {}),
            ),
            Text(
              "Recieve Mail",
              style: TextStyle(fontSize: 18.0),
            )
          ],
        ),

Not sure if I'm going to help here, but as it looks like you are right on the fact that the CheckBox size cannot be changed when added through a CheckBoxListTile Widget.不确定我是否会在这里提供帮助,但看起来你是对的,即通过 CheckBoxListTile 小部件添加时无法更改 CheckBox 大小。

Though, you could also create your own tile by inserting a Row for each tile you're using:不过,您也可以通过为您使用的每个图块插入一个 Row 来创建自己的图块:

Row(
 children: [
  Icon(Icons.attach_money),
  Text("Sinal"),
  Transform(
   transform: myTransform, // I don't remember the correct syntax for this one
   child: Checkbox(
    value: true,
    onChanged: (_) {},
   ),
  ),
 ]
),

The only thing you'll have to add is to dynamically change the Icon, Text and Checkbox sizes based on the device.您唯一需要添加的是根据设备动态更改图标、文本和复选框的大小。 (you could use MediaQuery.of(context).size in order to achieve this) (您可以使用MediaQuery.of(context).size来实现这一点)

     return Scaffold(
  body: Container(
    width: size.width,
    height: size.height,
    child: Center(
          child: new StatefulBuilder(
            builder: (BuildContext context, StateSetter setState) {
              return new Transform.scale(
                scale: 1.2,
                child:  Checkbox(
                   value: isChecked,
                    onChanged: (bool? value) {
                      setState(() {
                        isChecked = value!;
                      });
                    },
                ),
              );
            },
          ),
        ),
      ),


  );

did you find any solution @Rafael Honda您找到任何解决方案了吗@Rafael Honda

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

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