buildOperationAvatar method
Implementation
Widget buildOperationAvatar(BuildContext context) {
var list = <Widget>[];
if ((avatarDisplayList == null || avatarDisplayList!.isEmpty) && (avatarDisplayListAsset == null || avatarDisplayListAsset!.isEmpty)) {
return Container();
}
var length = 0;
if (avatarDisplayList != null) {
length = avatarDisplayList!.length;
for (var i = 0; i < avatarDisplayList!.length + 1; i++) {
var left = (_getAvatarWidth() - _getDisplayPadding()) * i;
if (i == avatarDisplayList!.length) {
list.add(Positioned(
left: left,
child: GestureDetector(
onTap: () {
if (onTap != null) {
onTap!();
}
},
child: Container(
child: Center(
child: Icon(TDIcons.user_add,
size: _getIconWidth(),
color: TDTheme.of(context).brandNormalColor),
),
width: _getAvatarWidth(),
height: _getAvatarWidth(),
clipBehavior: Clip.hardEdge,
decoration: ShapeDecoration(
color: TDTheme.of(context).brandColor2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
_getAvatarWidth() - _getDisplayPadding()),
side: BorderSide(
color: Colors.white,
width: avatarDisplayBorder)),
)),
)));
} else {
list.add(Positioned(
left: left,
child: Container(
width: _getAvatarWidth(),
height: _getAvatarWidth(),
clipBehavior: Clip.antiAlias,
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
_getAvatarWidth() - _getDisplayPadding()),
side: BorderSide(
color: Colors.white,
width: avatarDisplayBorder)),
image: DecorationImage(
image: NetworkImage(avatarDisplayList![i]),
fit: BoxFit.cover)))));
}
}
} else if (avatarDisplayListAsset != null) {
length = avatarDisplayListAsset!.length;
for (var i = 0; i < avatarDisplayListAsset!.length + 1; i++) {
var left = (_getAvatarWidth() - _getDisplayPadding()) * i;
if (i == avatarDisplayListAsset!.length) {
list.add(Positioned(
left: left,
child: GestureDetector(
onTap: () {
if (onTap != null) {
onTap!();
}
},
child: Container(
child: Center(
child: avatarDisplayWidget ?? Icon(TDIcons.user_add,
size: _getIconWidth(),
color: TDTheme.of(context).brandNormalColor),
),
width: _getAvatarWidth(),
height: _getAvatarWidth(),
clipBehavior: Clip.hardEdge,
decoration: ShapeDecoration(
color: TDTheme.of(context).brandColor2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
_getAvatarWidth() - _getDisplayPadding()),
side: BorderSide(
color: Colors.white,
width: avatarDisplayBorder)),
)),
)));
} else {
list.add(Positioned(
left: left,
child: Container(
width: _getAvatarWidth(),
height: _getAvatarWidth(),
clipBehavior: Clip.antiAlias,
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
_getAvatarWidth() - _getDisplayPadding()),
side: BorderSide(
color: Colors.white,
width: avatarDisplayBorder)),
image: DecorationImage(
image: AssetImage(avatarDisplayListAsset![i]),
fit: BoxFit.fill)))));
}
}
}
return SizedBox(
height: _getAvatarWidth(),
width: _getAvatarWidth() * (length + 1) -
length * _getDisplayPadding(),
child: Stack(children: list),
);
}