Skip to content

Instantly share code, notes, and snippets.

@rohankandwal
Created November 27, 2019 11:05
Show Gist options
  • Save rohankandwal/89e90600481d3de18b2a6410458932ad to your computer and use it in GitHub Desktop.
Save rohankandwal/89e90600481d3de18b2a6410458932ad to your computer and use it in GitHub Desktop.
Adding divider to Flutter's ListView using a Separator
@override
Widget build(BuildContext context) {
return ListView.separated(
padding: EdgeInsets.only(top: 8),
separatorBuilder: (context, index) => Divider(
height: 2,
color: Colors.red,
),
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(list[index].title),
leading: Image.network(list[index].image_url),
subtitle: Text(list[index].subtitle),
);
},
itemCount: list.length,
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment