Refactoring + Version améliorée
This commit is contained in:
41
lib/presentation/widgets/event_image.dart
Normal file
41
lib/presentation/widgets/event_image.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class EventImage extends StatelessWidget {
|
||||
final String? imageUrl;
|
||||
final double aspectRatio;
|
||||
|
||||
const EventImage({Key? key, this.imageUrl, this.aspectRatio = 16 / 9}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
child: AspectRatio(
|
||||
aspectRatio: aspectRatio,
|
||||
child: imageUrl != null && imageUrl!.isNotEmpty
|
||||
? Image.network(
|
||||
imageUrl!,
|
||||
width: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return _buildPlaceholderImage();
|
||||
},
|
||||
)
|
||||
: _buildPlaceholderImage(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPlaceholderImage() {
|
||||
return Container(
|
||||
color: Colors.grey[800],
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.image_not_supported,
|
||||
color: Colors.grey[400],
|
||||
size: 50,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user