From 0db351fa879659b4d33425d891b95f4b3d30d917 Mon Sep 17 00:00:00 2001 From: kvs Date: Fri, 28 May 2021 11:03:33 +0200 Subject: [PATCH] Map return for deleteObjects --- ios/Classes/SwiftHealthKitReporterPlugin.swift | 4 ++-- lib/health_kit_reporter.dart | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ios/Classes/SwiftHealthKitReporterPlugin.swift b/ios/Classes/SwiftHealthKitReporterPlugin.swift index 3c48181..7d10bda 100644 --- a/ios/Classes/SwiftHealthKitReporterPlugin.swift +++ b/ios/Classes/SwiftHealthKitReporterPlugin.swift @@ -1355,7 +1355,7 @@ extension SwiftHealthKitReporterPlugin { reporter.writer.deleteObjects( of: type, predicate: predicate - ) { (success, id, error) in + ) { (success, count, error) in guard error == nil else { result( FlutterError( @@ -1368,7 +1368,7 @@ extension SwiftHealthKitReporterPlugin { } let resultDictionary: [String: Any] = [ "status": success, - "id": id + "count": count ] result(resultDictionary) } diff --git a/lib/health_kit_reporter.dart b/lib/health_kit_reporter.dart index b78eb65..19510f1 100644 --- a/lib/health_kit_reporter.dart +++ b/lib/health_kit_reporter.dart @@ -633,13 +633,16 @@ class HealthKitReporter { /// Deletes all objects related to [identifier] with [predicate]. /// - static Future deleteObjects( + static Future> deleteObjects( String identifier, Predicate predicate) async { final arguments = { 'identifier': identifier, }; arguments.addAll(predicate.map); - return await _methodChannel.invokeMethod('deleteObjects', arguments); + final result = + await _methodChannel.invokeMethod('deleteObjects', arguments); + final Map map = jsonDecode(result); + return map; } /// Saves [Sample] in [HealthKit].