Reputation: 1088
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,
);
}
Upvotes: 2
Views: 4751
Reputation: 79
return RadioListTile(
contentPadding: EdgeInsets.zero,
dense: true,
value: name[index],
title: Transform.translate(
offset: Offset(-15, 0),
child: Text(
name[index].toString(),
style: TextStyle(fontSize: 12),
),
),
groupValue: _.currentname,
onChanged: (data) {
//on change function
});
Try with this simple widget i have using translate function and offset properties to negative 15points. Hope it will help you.
Upvotes: 1
Reputation: 479
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,
Upvotes: 1
Reputation: 2097
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);
},
);
Upvotes: 3
Reputation: 553
if you want to remove space horizontally then use
contentPadding: EdgeInsets.all(4.0),
inside RadioListTile which remove space bydefault is 16.0.
Upvotes: 1
Reputation: 489
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);
}
),
);
Upvotes: 0