简体   繁体   中英

Flutter - how to change CheckboxListTile size?

How can I change only the checkbox icon size on a 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. On a tablet screen the size is too small as you can see in the image.

平板电脑和手机

No worries., Its better then use 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.

Though, you could also create your own tile by inserting a Row for each tile you're using:

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)

     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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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