This commit is contained in:
2022-10-19 10:54:45 +08:00
commit 153e28aa4e
115 changed files with 4215 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:chat/configs/app_colors.dart';
import 'package:flutter/material.dart';
// ignore: must_be_immutable
class CustomCircleAvatar extends StatelessWidget {
String? avtarUrl;
double size;
Color borderColor;
double borderWidth;
CustomCircleAvatar(
this.avtarUrl, {
Key? key,
this.size = 44,
this.borderColor = AppColors.transparent,
this.borderWidth = 2,
}) : super(key: key);
@override
Widget build(BuildContext context) {
if (avtarUrl == null || avtarUrl == '') {
avtarUrl = 'assets/chats/default_avatar.png';
}
return Container(
width: size,
height: size,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(size / 2),
border: Border.all(
color: borderColor,
width: borderWidth,
),
),
child: PhysicalModel(
color: borderColor.withOpacity(0.1),
shape: BoxShape.circle,
clipBehavior: Clip.antiAlias,
child: _image(),
),
);
}
Widget _image() {
if (avtarUrl!.contains('http')) {
return CachedNetworkImage(
imageUrl: avtarUrl!,
width: size,
height: size,
fit: BoxFit.cover,
);
} else {
return Image.asset(
avtarUrl!,
width: size,
height: size,
fit: BoxFit.cover,
);
}
}
}