Fix avatar
This commit is contained in:
parent
ddf2eb3204
commit
81287ccfe1
|
@ -23,7 +23,7 @@ class Avatar extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final String src = mxContent.getThumbnail(
|
final String src = mxContent?.getThumbnail(
|
||||||
Matrix.of(context).client,
|
Matrix.of(context).client,
|
||||||
width: size * MediaQuery.of(context).devicePixelRatio,
|
width: size * MediaQuery.of(context).devicePixelRatio,
|
||||||
height: size * MediaQuery.of(context).devicePixelRatio,
|
height: size * MediaQuery.of(context).devicePixelRatio,
|
||||||
|
@ -35,20 +35,21 @@ class Avatar extends StatelessWidget {
|
||||||
} else if ((name?.length ?? 0) == 1) {
|
} else if ((name?.length ?? 0) == 1) {
|
||||||
fallbackLetters = name;
|
fallbackLetters = name;
|
||||||
}
|
}
|
||||||
|
final noPic = mxContent == null || mxContent.toString().isEmpty;
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
radius: size / 2,
|
radius: size / 2,
|
||||||
backgroundImage: mxContent != null
|
backgroundImage: !noPic
|
||||||
? AdvancedNetworkImage(
|
? AdvancedNetworkImage(
|
||||||
src,
|
src,
|
||||||
useDiskCache: !kIsWeb,
|
useDiskCache: !kIsWeb,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
backgroundColor: mxContent == null
|
backgroundColor: noPic
|
||||||
? name?.color ?? Theme.of(context).secondaryHeaderColor
|
? name?.color ?? Theme.of(context).secondaryHeaderColor
|
||||||
: Theme.of(context).secondaryHeaderColor,
|
: Theme.of(context).secondaryHeaderColor,
|
||||||
child: mxContent == null
|
child: noPic
|
||||||
? Text(fallbackLetters, style: TextStyle(color: Colors.white))
|
? Text(fallbackLetters, style: TextStyle(color: Colors.white))
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue