feat: add BoxFit to avatar

This commit is contained in:
mike doornenbal 2024-07-15 16:49:55 +02:00
parent 6b292175ab
commit fe2dd0f169
2 changed files with 5 additions and 1 deletions

View file

@ -1,6 +1,7 @@
## 1.5.0 ## 1.5.0
- Updated flutter_input_library to 3.2.1 - Updated flutter_input_library to 3.2.1
- Added the option to give a `BoxFit` to the avatar image
## 1.4.0 ## 1.4.0

View file

@ -12,6 +12,7 @@ class Avatar extends StatelessWidget {
this.user, this.user,
this.size = 100, this.size = 100,
this.avatarBackgroundColor, this.avatarBackgroundColor,
this.boxfit = BoxFit.contain,
}); });
/// The user object containing user information. /// The user object containing user information.
@ -23,6 +24,8 @@ class Avatar extends StatelessWidget {
/// Background color of the avatar. /// Background color of the avatar.
final Color? avatarBackgroundColor; final Color? avatarBackgroundColor;
final BoxFit boxfit;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var imageProvider = _getImageProvider(user); var imageProvider = _getImageProvider(user);
@ -42,7 +45,7 @@ class Avatar extends StatelessWidget {
image: hasImage image: hasImage
? DecorationImage( ? DecorationImage(
image: imageProvider, image: imageProvider,
fit: BoxFit.contain, fit: boxfit,
) )
: null, : null,
), ),