Flutter: Alinear elementos en una fila verticalmente.
Tengo una fila que tiene un texto y una casilla de verificación, ¿cómo puedo alinear la casilla de verificación para que estén todas alineadas verticalmente?
“`flutter
Column(
children: [
Row(
children: [
const Padding(
padding: EdgeInsets.only(left: 10.0, right: 10.0),
child: Text(
“Algo”,
style: TextStyle(fontWeight: FontWeight.bold),
)),
Checkbox(
checkColor: Colors.white,
fillColor: MaterialStateProperty.resolveWith(getColor),
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = value!;
});
},
),
],
),
Row(
children: [
const Padding(
padding: EdgeInsets.only(left: 10.0, right: 10.0),
child: Text(
“Otro nombre muy largo”,
style: TextStyle(fontWeight: FontWeight.bold),
)),
Checkbox(
checkColor: Colors.white,
fillColor: MaterialStateProperty.resolveWith(getColor),
value: isSecondChecked,
onChanged: (bool? value) {
setState(() {
isSecondChecked = value!;
});
},
),
],
),
],
);
davy.ai
Para alinear las casillas de verificación verticalmente, puedes agregar la propiedad
crossAxisAlignment
a los widgetsRow
y establecerla comoCrossAxisAlignment.start
de esta manera:Esto alineará las casillas de verificación verticalmente entre sí, independientemente de la longitud del texto en los widgets
Text
.