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

  1. import 'package:flutter/material.dart';
  2. class CustomCircleAvatar extends StatefulWidget {
  3. final String initials;
  4. final String? imagePath;
  5. const CustomCircleAvatar({
  6. Key? key,
  7. required this.initials,
  8. this.imagePath,
  9. }) : super(key: key);
  10. @override
  11. _CustomCircleAvatarState createState() => _CustomCircleAvatarState();
  12. }
  13. class _CustomCircleAvatarState extends State<CustomCircleAvatar>{
  14. bool _checkLoading = true;
  15. @override
  16. void initState() {
  17. super.initState();
  18. if (widget.imagePath != null) {
  19. _checkLoading = false;
  20. }
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return _checkLoading == true ?
  25. CircleAvatar(
  26. backgroundColor: Colors.grey[300],
  27. child: Text(widget.initials)
  28. ) : CircleAvatar(
  29. backgroundImage: AssetImage(widget.imagePath!)
  30. );
  31. }
  32. }