From cc4c55a2c0e6490557692954ff58a51ed43b4179 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Thu, 24 Mar 2022 15:04:33 -0300 Subject: [PATCH] Fix file manager page issue Fixed the issue of the list view not destroying properly its cards once the files got uploaded. --- lib/pages/file_manager_page.dart | 72 +++++++++++++++----------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/lib/pages/file_manager_page.dart b/lib/pages/file_manager_page.dart index 1a450fc..e1834f7 100644 --- a/lib/pages/file_manager_page.dart +++ b/lib/pages/file_manager_page.dart @@ -37,47 +37,43 @@ class _FileManagerPage extends State { builder: (c, snapshot) => Column( children: snapshot.data! .map( - (f) => Card( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - leading: IconButton( - icon: Icon(Icons.folder_open_sharp), + (deviceMeasurementsFile) => Card( + key: Key(deviceMeasurementsFile.path), + child: ListTile( + leading: IconButton( + icon: Icon(Icons.folder_open_sharp), + onPressed: () async { + BufferedSensorMeasurements measurements = + await deviceMeasurementsFile.readJsonContent(); + Navigator.pushNamed( + context, + FileContentChartPage.routeName, + arguments: measurements, + ); + }, + ), + title: Text(basename(deviceMeasurementsFile.path)), + subtitle: Text(deviceMeasurementsFile.lastModified), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + icon: Icon(Icons.delete_outline_outlined, + color: Theme.of(context) + .iconTheme + .color + ?.withOpacity(0.5)), onPressed: () async { - BufferedSensorMeasurements measurements = - await f.readJsonContent(); - Navigator.pushNamed( - context, - FileContentChartPage.routeName, - arguments: measurements, - ); + await deviceMeasurementsFile.deleteFile(); + //refresh + setState(() {}); }, ), - title: Text(basename(f.path)), - subtitle: Text(f.lastModified), - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - icon: Icon(Icons.delete_outline_outlined, - color: Theme.of(context) - .iconTheme - .color - ?.withOpacity(0.5)), - onPressed: () async { - await f.deleteFile(); - //refresh - setState(() {}); - }, - ), - UploadButton( - onButtonPressed: () => - uploadFileCallBack(f)) - ], - ), - ), - ], + UploadButton( + onButtonPressed: () => + uploadFileCallBack(deviceMeasurementsFile)) + ], + ), ), ), )