leadingWidget property
Widget?
get
leadingWidget
Implementation
Widget? get leadingWidget {
if (profileImage.isNotEmpty) {
return Container(
width: 48,
height: 48,
alignment: Alignment.center,
child: CachedNetworkImage(
imageUrl: profileImage,
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
),
placeholder: (context, url) => Center(
child: CircularProgressIndicator(),
),
errorWidget: (context, url, error) => Icon(Icons.error),
),
);
} else if (profileName.isNotEmpty) {
String name = "";
List<String> profileNameSplitted = profileName.trim().split(" ");
if (profileNameSplitted.length >= 2) {
name = profileNameSplitted[0][0].toUpperCase() +
(profileNameSplitted[1].length > 0
? profileNameSplitted[1][0]
: profileNameSplitted[0][1])
.toUpperCase();
} else if (profileNameSplitted.length == 1) {
name = profileNameSplitted[0][0].toUpperCase() +
profileNameSplitted[0][1].toUpperCase();
;
}
return CircleAvatar(
backgroundColor: getBackGroundColor(profileName),
child: Text(
name,
style: TextStyle(
color: Colors.white,
),
),
);
}
return null;
}