Avatar.dart 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import 'package:flutter/material.dart';
  2. import '../../basic/Entities.dart';
  3. import 'Images.dart';
  4. const double _avatarMargin = 5;
  5. const double _avatarBorderSize = 1.5;
  6. // 头像
  7. class Avatar extends StatelessWidget {
  8. final RemoteImageInfo avatarImage;
  9. final double size;
  10. const Avatar(this.avatarImage, {this.size = 50, Key? key}) : super(key: key);
  11. @override
  12. Widget build(BuildContext context) {
  13. var theme = Theme.of(context);
  14. return Container(
  15. margin: const EdgeInsets.all(_avatarMargin),
  16. decoration: BoxDecoration(
  17. shape: BoxShape.circle,
  18. border: Border.all(
  19. color: theme.colorScheme.secondary,
  20. style: BorderStyle.solid,
  21. width: _avatarBorderSize,
  22. )),
  23. child: ClipRRect(
  24. borderRadius: BorderRadius.all(Radius.circular(size)),
  25. child: RemoteImage(
  26. fileServer: avatarImage.fileServer,
  27. path: avatarImage.path,
  28. width: size,
  29. height: size,
  30. ),
  31. ),
  32. );
  33. }
  34. }