Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
918 B

import 'package:flutter/material.dart';
class CustomCircleAvatar extends StatefulWidget {
final String initials;
final String? imagePath;
const CustomCircleAvatar({
Key? key,
required this.initials,
this.imagePath,
}) : super(key: key);
@override
_CustomCircleAvatarState createState() => _CustomCircleAvatarState();
}
class _CustomCircleAvatarState extends State<CustomCircleAvatar>{
bool _checkLoading = true;
@override
void initState() {
super.initState();
if (widget.imagePath != null) {
_checkLoading = false;
}
}
@override
Widget build(BuildContext context) {
return _checkLoading == true ?
CircleAvatar(
backgroundColor: Colors.grey[300],
child: Text(widget.initials)
) : CircleAvatar(
backgroundImage: AssetImage(widget.imagePath!)
);
}
}