From b0947d19d067ca987f5dc2a51dc890708e1f7967 Mon Sep 17 00:00:00 2001 From: bardram Date: Wed, 3 Apr 2024 14:03:17 +0200 Subject: [PATCH] Update main.dart --- packages/health/example/lib/main.dart | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/health/example/lib/main.dart b/packages/health/example/lib/main.dart index 84e93cf07..2e77ab376 100644 --- a/packages/health/example/lib/main.dart +++ b/packages/health/example/lib/main.dart @@ -131,23 +131,23 @@ class _HealthAppState extends State { // Clear old data points _healthDataList.clear(); - // try { - // fetch health data - List healthData = await Health().getHealthDataFromTypes( - types: types, - startTime: yesterday, - endTime: now, - ); + try { + // fetch health data + List healthData = await Health().getHealthDataFromTypes( + types: types, + startTime: yesterday, + endTime: now, + ); - debugPrint('Total number of data points: ${healthData.length}. ' - '${healthData.length > 100 ? 'Only showing the first 100.' : ''}'); + debugPrint('Total number of data points: ${healthData.length}. ' + '${healthData.length > 100 ? 'Only showing the first 100.' : ''}'); - // save all the new data points (only the first 100) - _healthDataList.addAll( - (healthData.length < 100) ? healthData : healthData.sublist(0, 100)); - // } catch (error) { - // debugPrint("Exception in getHealthDataFromTypes: $error"); - // } + // save all the new data points (only the first 100) + _healthDataList.addAll( + (healthData.length < 100) ? healthData : healthData.sublist(0, 100)); + } catch (error) { + debugPrint("Exception in getHealthDataFromTypes: $error"); + } // filter out duplicates _healthDataList = Health().removeDuplicates(_healthDataList);