12345678910111213141516171819202122232425262728293031323334 |
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:eitc_erm_app/utils/logger.dart';
- import 'package:flutter/material.dart';
- import 'image_error.dart';
- ///用户头像
- class UserHeader extends StatelessWidget {
- final String url;
- final double radius;
- final Widget? placeHolder;
- const UserHeader(
- {super.key, this.url = "", this.radius = 30, this.placeHolder});
- @override
- Widget build(BuildContext context) {
- return CircleAvatar(
- radius: radius,
- backgroundColor: Colors.transparent,
- foregroundImage: CachedNetworkImageProvider(url),
- onForegroundImageError: (e, stack) {
- loge("图片加载异常,url=$url", error: "$e");
- },
- child: placeHolder ??
- const ImageError(
- icon: Icons.account_circle,
- size: 60,
- color: Colors.grey,
- ),
- );
- }
- }
|