Home > Net >  Any widgets in flutter allow me to have a profile picture but if they don't have one the initia
Any widgets in flutter allow me to have a profile picture but if they don't have one the initia

Time:10-25

Im trying to make a flutter app for HR and for my employee's section I need to have it so that their initials are shown if a profile picture is unavailable is there a widget which allows me to do this?

Below is an example of what im trying to achieve

This is an Example of what im trying to achieve

CodePudding user response:

You can try it with CachedNetworkImage

CachedNetworkImage(
            imageUrl: "http://myimage...",
            placeholder: (context, url) => new CircularProgressIndicator(),
            errorWidget: (context, url, error) => new Text("my initials here"),
         ),

CodePudding user response:

You need to Do Something Like This, but first Need to check for Image thats depends on how you are managing data and then
_isImageAvailable ? ProfileImage() : Text(Name)

CodePudding user response:

Container(
        height: 100.0,
        width: 100.0,
        color: Colors.grey,
        child: ClipRRect(
          borderRadius: BorderRadius.circular(8.0),
          child: hasImage
              ? Image.network(
                  imageUrl,
                  fit: BoxFit.contain,
                )
              : Center(
                  child: Text('$nameInitial'),
                ),
        ),
      )
  • Related