'How to remove/adjust the space between RadioListTiles inside ListView?
I have created a ListView of RadioListTiles, however there is too much space between the RadioListTiles. How can I remove them? There is no property of padding inside its constructor.
This is my code
@override Widget build(BuildContext context) {
Column taskView = Column(
children: <Widget>[
...,
Expanded(
child: ListView.builder(
padding: EdgeInsets.all(0.0),
itemCount: tasks.length,
itemBuilder: (context, index) {
return RadioListTile<String>(
title: Text(tasks[index]),
value: tasks[index],
groupValue: selectedRadio,
onChanged: (val){
setSelectedRadio(val);
}
);
},
),
),
],
);
return Scaffold(
body: taskView,
);
}
Solution 1:[1]
Wrap title with Align widget like this
RadioListTile<String>(
title: Align(
child: Text(tasks[index]),
alignment: Alignment(-1.1, 0),
),
value: tasks[index],
groupValue: selectedRadio,
onChanged: (val) {
setSelectedRadio(val);
},
);
Solution 2:[2]
you can try padding control to wrap your text or RadioListFile.. try this way..
return Padding(
padding: const EdgeInsets.all(8.0),
child: RadioListTile<String>(
title: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(tasks[index]),
),
value: tasks[index],
groupValue: selectedRadio,
onChanged: (val){
setSelectedRadio(val);
}
),
);
Solution 3:[3]
if you want to remove space horizontally then use
contentPadding: EdgeInsets.all(4.0),
inside RadioListTile which remove space bydefault is 16.0.
Solution 4:[4]
To remove horizontal padding use this property:
contentPadding: EdgeInsets.zero,
For vertical padding all I could do to decrease padding a little bit is:
dense: true,
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 | Hemal Moradiya |
| Solution 2 | Infusion Analysts |
| Solution 3 | Adnan haider |
| Solution 4 | Aziz |

