lots of stuff
This commit is contained in:
parent
8bc010cfc7
commit
ba9e99a951
19 changed files with 608 additions and 360 deletions
38
lib/widgets/avatar_or_hash.dart
Normal file
38
lib/widgets/avatar_or_hash.dart
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import "package:color_hash/color_hash.dart";
|
||||
import "package:flutter/widgets.dart";
|
||||
|
||||
class AvatarOrHash extends StatelessWidget {
|
||||
final Uri? avatar;
|
||||
final String title;
|
||||
final Widget? fallback;
|
||||
final Map<String, String> headers;
|
||||
const AvatarOrHash(
|
||||
this.avatar,
|
||||
this.title, {
|
||||
this.fallback,
|
||||
required this.headers,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final box = ColoredBox(
|
||||
color: ColorHash(title).color,
|
||||
child: Center(child: Text(title[0])),
|
||||
);
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(4)),
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: avatar == null
|
||||
? fallback ?? box
|
||||
: Image.network(
|
||||
avatar.toString(),
|
||||
headers: headers,
|
||||
errorBuilder: (_, _, _) => box,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue