@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
22import 'dart:io' ;
33
44class HistoryPage extends StatelessWidget {
5- final List <File > predictedImages; // Liste des images prédites
5+ final List <Map < String , dynamic >> predictedImages; // Liste des images prédites avec leurs résultats
66
77 const HistoryPage ({Key ? key, required this .predictedImages}) : super (key: key);
88
@@ -12,15 +12,35 @@ class HistoryPage extends StatelessWidget {
1212 appBar: AppBar (
1313 title: const Text ('History' ),
1414 ),
15- body: ListView .builder (
15+ body: predictedImages.isNotEmpty
16+ ? ListView .builder (
1617 itemCount: predictedImages.length,
1718 itemBuilder: (context, index) {
1819 int reversedIndex = predictedImages.length - 1 - index;
20+ Map <String , dynamic > imageData = predictedImages[reversedIndex];
21+ File imageFile = imageData['image' ];
22+ Map resultDict = imageData['result' ];
23+ String mostProbablePrediction = resultDict['confidences' ][0 ]['label' ];
24+
1925 return ListTile (
20- leading: Image .file (predictedImages[reversedIndex] , width: 50 , height: 50 ),
21- title: Text ('Image ${ index + 1 } ' ),
26+ leading: Image .file (imageFile , width: 50 , height: 50 ),
27+ title: Text ('$ mostProbablePrediction ' ),
2228 );
2329 },
30+ )
31+ : const Column (
32+ mainAxisAlignment: MainAxisAlignment .start,
33+ children: [
34+ Padding (
35+ padding: EdgeInsets .only (top: 16.0 ),
36+ child: Center (
37+ child: Text (
38+ "Empty history..." ,
39+ style: TextStyle (fontSize: 18 ),
40+ ),
41+ ),
42+ ),
43+ ],
2444 ),
2545 );
2646 }
0 commit comments