perf: ajout de ListView itemExtent/prototypeItem pour l'optimisation des performances
This commit is contained in:
@@ -601,80 +601,92 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: isMobile ? 240 : 280,
|
||||
),
|
||||
child: ListView.separated(
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: _searchResults.length,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
separatorBuilder: (context, index) =>
|
||||
const SizedBox(height: 8),
|
||||
// ✅ prototypeItem : les résultats ont une hauteur variable
|
||||
// selon la présence du champ adresse (~56px sans, ~70px avec).
|
||||
// prototypeItem à 72px (cas avec adresse + padding) pour
|
||||
// que Flutter estime correctement la hauteur scrollable.
|
||||
// ListView.separated ne supporte pas itemExtent/prototypeItem,
|
||||
// d'où la conversion en ListView.builder avec séparateur intégré.
|
||||
prototypeItem: const SizedBox(height: 72),
|
||||
itemBuilder: (context, index) {
|
||||
final event = _searchResults[index];
|
||||
final isSelected = _selectedEvent?.id == event.id;
|
||||
final isLast = index == _searchResults.length - 1;
|
||||
|
||||
return Material(
|
||||
color: isSelected
|
||||
? AppColors.rouge.withOpacity(0.08)
|
||||
: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: () => _onSearchResultSelected(event),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: _getStatusColor(event.status),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
event.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Material(
|
||||
color: isSelected
|
||||
? AppColors.rouge.withOpacity(0.08)
|
||||
: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: () => _onSearchResultSelected(event),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: _getStatusColor(event.status),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_formatSearchResultDate(
|
||||
event.startDateTime),
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade700,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
if (event.address.isNotEmpty) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
event.address,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade600,
|
||||
fontSize: 12,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
event.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_formatSearchResultDate(
|
||||
event.startDateTime),
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade700,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
if (event.address.isNotEmpty) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
event.address,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade600,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(Icons.chevron_right,
|
||||
color: Colors.grey),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(Icons.chevron_right,
|
||||
color: Colors.grey),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!isLast) const SizedBox(height: 8),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user