I am playing with Checkbox to see how it works, but I don't see a title option with it.
Checkbox( title: Text("Checkbox label"), // The named parameter 'title' isn't defined. value: true, onChanged: (newValue) { }, );
Do I have to create my own widget to add a title to it?
label. Optional widget that describes the input field. When the input field is empty and unfocused, the label is displayed on top of the input field (i.e., at the same location on the screen where text may be entered in the input field).
If you need a Checkbox
with a label then you can use a CheckboxListTile
.
CheckboxListTile( title: Text("title text"), // <-- label value: checkedValue, onChanged: (newValue) { ... }, )
If you want the checkbox on the left of the text then you can set the controlAffinity
parameter.
CheckboxListTile( title: Text("title text"), value: checkedValue, onChanged: (newValue) { ... }, controlAffinity: ListTileControlAffinity.leading, // <-- leading Checkbox )
onChanged()
callback. You need to rebuild it with the correct checked values yourself, though. See this answer.onChanged()
callback. You could start with the CheckboxListTile
source code as a reference.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With