From d828bfcc912f39a8702d1cc4f059501ec3a4ba88 Mon Sep 17 00:00:00 2001 From: Sardar1208 Date: Fri, 27 Oct 2023 15:04:40 +0530 Subject: [PATCH 1/2] fix: fixed contacts refetching when already present --- .../example/ios/Podfile.lock | 26 ++++++++++++++----- .../Flutter/GeneratedPluginRegistrant.swift | 2 +- .../lib/services/contact_service.dart | 12 ++++----- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/packages/at_contacts_flutter/example/ios/Podfile.lock b/packages/at_contacts_flutter/example/ios/Podfile.lock index 7bce9657..b264d4ea 100644 --- a/packages/at_contacts_flutter/example/ios/Podfile.lock +++ b/packages/at_contacts_flutter/example/ios/Podfile.lock @@ -9,6 +9,8 @@ PODS: - Flutter - biometric_storage (0.0.1): - Flutter + - device_info_plus (0.0.1): + - Flutter - DKImagePickerController/Core (4.3.4): - DKImagePickerController/ImageDataManager - DKImagePickerController/Resource @@ -43,6 +45,8 @@ PODS: - file_picker (0.0.1): - DKImagePickerController/PhotoGallery - Flutter + - file_selector_ios (0.0.1): + - Flutter - Flutter (1.0.0) - flutter_keychain (0.0.1): - Flutter @@ -52,7 +56,7 @@ PODS: - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS - - permission_handler_apple (9.0.4): + - permission_handler_apple (9.1.1): - Flutter - qr_code_scanner (0.2.0): - Flutter @@ -77,7 +81,9 @@ DEPENDENCIES: - at_file_saver (from `.symlinks/plugins/at_file_saver/ios`) - at_onboarding_flutter (from `.symlinks/plugins/at_onboarding_flutter/ios`) - biometric_storage (from `.symlinks/plugins/biometric_storage/ios`) + - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - file_picker (from `.symlinks/plugins/file_picker/ios`) + - file_selector_ios (from `.symlinks/plugins/file_selector_ios/ios`) - Flutter (from `Flutter`) - flutter_keychain (from `.symlinks/plugins/flutter_keychain/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) @@ -108,8 +114,12 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/at_onboarding_flutter/ios" biometric_storage: :path: ".symlinks/plugins/biometric_storage/ios" + device_info_plus: + :path: ".symlinks/plugins/device_info_plus/ios" file_picker: :path: ".symlinks/plugins/file_picker/ios" + file_selector_ios: + :path: ".symlinks/plugins/file_selector_ios/ios" Flutter: :path: Flutter flutter_keychain: @@ -137,23 +147,25 @@ SPEC CHECKSUMS: at_file_saver: c0e052c72d8c0296318bd70f2ae7f510887014ce at_onboarding_flutter: e8219b6d0bfb236d3837ec3528871aebdcc56e8d biometric_storage: 1400f1382af3a4cc2bf05340e13c3d8de873ceb9 + device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6 DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 file_picker: ce3938a0df3cc1ef404671531facef740d03f920 + file_selector_ios: 8c25d700d625e1dcdd6599f2d927072f2254647b Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_keychain: 01aabf894ffe8b01adfda1d9df21c210c1b4b452 MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb - package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7 - path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8 - permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce + package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85 + path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 + permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6 qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e SDWebImage: fd7e1a22f00303e058058278639bf6196ee431fe - share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68 - shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 + share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5 + shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 -COCOAPODS: 1.11.3 +COCOAPODS: 1.12.1 diff --git a/packages/at_contacts_flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift b/packages/at_contacts_flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift index 508252dd..591d027b 100644 --- a/packages/at_contacts_flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/packages/at_contacts_flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -20,7 +20,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { BiometricStorageMacOSPlugin.register(with: registry.registrar(forPlugin: "BiometricStorageMacOSPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) - FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) diff --git a/packages/at_contacts_flutter/lib/services/contact_service.dart b/packages/at_contacts_flutter/lib/services/contact_service.dart index 48faa276..3ae92775 100644 --- a/packages/at_contacts_flutter/lib/services/contact_service.dart +++ b/packages/at_contacts_flutter/lib/services/contact_service.dart @@ -135,18 +135,16 @@ class ContactService { try { /// if contact list is already present, data is not fetched again if (baseContactList.isNotEmpty) { - List baseContacts = - baseContactList.map((e) => e.contact).toList(); - baseContacts.sort((a, b) { - int? index = a?.atSign + baseContactList.sort((a, b) { + int? index = a.contact?.atSign .toString() .substring(1) - .compareTo((b?.atSign).toString().substring(1)); + .compareTo((b.contact?.atSign).toString().substring(1)); return index ?? 0; }); - if (baseContacts == contactList) { + if (baseContactList.length == contactList.length) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { - contactSink.add(baseContacts); + contactSink.add(baseContactList); }); return contactList; } From e219d536a8ff90831a58ef97dd18e9cd15bc6b4c Mon Sep 17 00:00:00 2001 From: Sardar1208 Date: Fri, 27 Oct 2023 17:19:21 +0530 Subject: [PATCH 2/2] fix: updated contacts comparision --- .../at_contacts_flutter/lib/services/contact_service.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/at_contacts_flutter/lib/services/contact_service.dart b/packages/at_contacts_flutter/lib/services/contact_service.dart index 3ae92775..1d8c68aa 100644 --- a/packages/at_contacts_flutter/lib/services/contact_service.dart +++ b/packages/at_contacts_flutter/lib/services/contact_service.dart @@ -10,6 +10,7 @@ import 'package:at_contacts_flutter/models/contact_base_model.dart'; import 'package:at_contacts_flutter/utils/init_contacts_service.dart'; import 'package:at_contacts_flutter/utils/text_strings.dart'; import 'package:at_lookup/at_lookup.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; /// A service to handle CRUD operation on contacts @@ -135,6 +136,8 @@ class ContactService { try { /// if contact list is already present, data is not fetched again if (baseContactList.isNotEmpty) { + List tempBaseContacts = + baseContactList.map((e) => e.contact).toList(); baseContactList.sort((a, b) { int? index = a.contact?.atSign .toString() @@ -142,7 +145,8 @@ class ContactService { .compareTo((b.contact?.atSign).toString().substring(1)); return index ?? 0; }); - if (baseContactList.length == contactList.length) { + var res = listEquals(tempBaseContacts, contactList); + if (res == true) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { contactSink.add(baseContactList); });