'How to increase width of ChoiceChip to same value for all?
I am using https://api.flutter.dev/flutter/material/ChoiceChip-class.html and I want to make them same size.
I found out this solution How to increase the width of a chip in flutter but padding is not solution because then width depends on text size so I am getting different width for every ChoiceChip.
I also tried with wrapping it with Container but this also didnt work for me.
ChoiceChip(
label: AutoSizeText(local.searchNoLocation),
selected: helperSelected == 3,
selectedColor: Color(0xffffcfcf),
labelStyle: TextStyle(
color: helperSelected == 3 ? Colors.red[300] : Colors.black),
onSelected: (_) {
setState(() => helperSelected = 3);
})
Solution 1:[1]
For making them actually the same size you need the label to have the same size. If you want them inside a Row or Column and using the same amount of space in the mainAxis, you can wrap them inside an Expanded widget.
Row(
children: const [
Expanded(
child: ChoiceChip(
selected: false,
label: Text('Bigger Text'),
),
),
Expanded(
child: ChoiceChip(
selected: false,
label: Text('Text'),
),
),
],
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Felipe Morschel |
