LabeledCheckbox (Checkbox) on the left side of the text in Flutter?

Viewed 33

I'm using CheckboxListTile, by default the checkbox is to the right of the text. How do I move the checkbox to the left of the text?

My code:

 @override
   Widget build(BuildContext context) {
     return LabeledCheckbox(
       label: 'Text of my Checkbox',
       padding: const EdgeInsets.symmetric(horizontal: 20.0),
       value: _isSelected,
       onChanged: (bool newValue) {
         setState(() {
           _isSelected = newValue;
         });
       },
     );
   }

Preview:

enter image description here

1 Answers

To make the checkbox appear on the left of the text, you can wrap your widget with a Directionality() and specify the textDirection to textDirection: TextDirection.rtl:

Directionality(
        textDirection: TextDirection.rtl,
        child: CheckboxListTile(
          value: false,
          onChanged: (bool? value) {},
          title: Text("My Text"),
        ),
      )

Result:

enter image description here

Related