47 lines
1.2 KiB
Dart
47 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
class TeamImage extends StatelessWidget {
|
|
final String? imageUrl;
|
|
final double size;
|
|
|
|
const TeamImage({Key? key, required this.imageUrl, this.size = 30})
|
|
: super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (imageUrl == null || imageUrl!.isEmpty) {
|
|
return const SizedBox();
|
|
}
|
|
|
|
final lowerUrl = imageUrl!.toLowerCase();
|
|
|
|
if (lowerUrl.contains('svg')) {
|
|
return SvgPicture.network(
|
|
imageUrl!,
|
|
width: size,
|
|
height: size,
|
|
placeholderBuilder:
|
|
(context) => const CircularProgressIndicator(strokeWidth: 1),
|
|
fit: BoxFit.cover,
|
|
);
|
|
} else {
|
|
return ClipOval(
|
|
child: Image.network(
|
|
imageUrl!,
|
|
width: size,
|
|
height: size,
|
|
fit: BoxFit.cover,
|
|
loadingBuilder: (context, child, loadingProgress) {
|
|
if (loadingProgress == null) return child;
|
|
return const CircularProgressIndicator(strokeWidth: 1);
|
|
},
|
|
errorBuilder:
|
|
(context, error, stackTrace) =>
|
|
const Icon(Icons.broken_image, size: 24, color: Colors.grey),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|