How can i add a network handling/placeholder in networkimage when the url return null?
body: Center(
child: ListView.builder(
itemCount: users.length,
itemBuilder: (BuildContext context, int index) {
User user = users[index];
return ListTile(
title: Text(user.firstName),
subtitle: Text(user.role),
leading: CircleAvatar(
backgroundImage: NetworkImage(user.avatar.toString()),
errorWidget: (context, url, error) => //this part not working
Icon(Icons.error),
),
onTap: () {});
})));
There are two way to show network image with error handling:
One: use Image.network
Two: