Skip to content

Instantly share code, notes, and snippets.

@Nash0x7E2
Created September 27, 2018 00:11
Show Gist options
  • Save Nash0x7E2/f980e59148957d7125d53f82bae96e8c to your computer and use it in GitHub Desktop.
Save Nash0x7E2/f980e59148957d7125d53f82bae96e8c to your computer and use it in GitHub Desktop.
//New
Widget _buildItem(UserModel user, [int index]) {
return ListTile(
key: ValueKey<UserModel>(user),
title: Text(user.firstName),
subtitle: Text(user.lastName),
leading: CircleAvatar(
backgroundImage: NetworkImage(user.profileImageUrl),
),
onLongPress: index != null ? () => deleteUser(index) : null,
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Animated List Demo"),
centerTitle: true,
leading: IconButton(
icon: Icon(Icons.add),
onPressed: addUser,
),
),
body: SafeArea(
child: AnimatedList(
key: _listKey,
initialItemCount: listData.length,
itemBuilder: (BuildContext context, int index, Animation animation) {
return FadeTransition(
opacity: animation,
child: _buildItem(listData[index], index), //Change
);
},
),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment