Files
Dart-Flutter/my_travel/lib/views/widgets/city_card.dart
2025-10-14 12:29:11 +02:00

68 lines
1.9 KiB
Dart

import 'package:flutter/material.dart';
class CityCard extends StatelessWidget {
final String name;
final String image;
final bool checked; // devient requis
final VoidCallback updateChecked;
const CityCard({
super.key,
required this.name,
required this.image,
required this.checked,
required this.updateChecked,
});
@override
Widget build(BuildContext context) {
return Card(
elevation: 5,
clipBehavior: Clip.antiAlias,
child: SizedBox(
height: 150,
child: Stack(
fit: StackFit.expand,
children: [
Ink.image(
image: AssetImage(image),
fit: BoxFit.cover,
child: InkWell(onTap: updateChecked), // notifie le parent
),
Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [
// Icône favori : pleine si checked, sinon contour
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(
checked ? Icons.star : Icons.star_border,
size: 30,
color: Colors.white,
),
],
),
),
Row(
children: [
Text(
name,
style: const TextStyle(
fontSize: 30,
color: Colors.white,
),
),
],
),
],
),
),
],
),
),
);
}
}