storePackages method

Future<void> storePackages(
  1. List<Map<String, dynamic>> serverResponse
)

Implementation

Future<void> storePackages(List<Map<String, dynamic>> serverResponse) async {
  if (!_isInitialized) throw Exception('PackageStorage not initialized');
  final box = _box!;
  await box.clear();
  // Store new packages
  for (final packageData in serverResponse) {
    try {
      final packageInfo = PackageInfo.fromJson(packageData);
      await box.put(packageInfo.packageName, packageInfo);
    } catch (e) {
      debugPrint('Error storing package: $packageData - $e');
    }
  }
}