You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
| import 'dart:convert';
 | |
| 
 | |
| import 'package:flutter/material.dart';
 | |
| 
 | |
| class CircularAvatar extends StatelessWidget {
 | |
|   final String? url;
 | |
|   final double radius;
 | |
|   final double width;
 | |
|   final double height;
 | |
|   final bool isImageBase64;
 | |
| 
 | |
|   CircularAvatar({Key? key, this.radius = 70.0, this.width = 70, this.height = 60, this.url, this.isImageBase64 = false}) : super(key: key);
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     return Container(
 | |
|       width: width,
 | |
|       height: height,
 | |
|       decoration: BoxDecoration(
 | |
|         shape: BoxShape.circle,
 | |
|         image: isImageBase64
 | |
|             ? null
 | |
|             : DecorationImage(
 | |
|                 fit: BoxFit.cover,
 | |
|                 image: NetworkImage(url ?? "https://cdn4.iconfinder.com/data/icons/professions-2-2/151/89-512.png"),
 | |
|               ),
 | |
|       ),
 | |
|       child: (isImageBase64 && url != null) ? imageFromBase64String(url!) : Container(),
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   Widget imageFromBase64String(String base64String) {
 | |
|     return ClipRRect(
 | |
|       borderRadius: BorderRadius.circular(100),
 | |
|       child: Image.memory(
 | |
|         base64Decode(base64String),
 | |
|         fit: BoxFit.cover,
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| }
 |