-
-
Save Nash0x7E2/f980e59148957d7125d53f82bae96e8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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