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!)
|
|
);
|
|
}
|
|
}
|