saveCookiePreferences method

  1. @override
Future<void> saveCookiePreferences(
  1. Map<String, dynamic> preferences
)
override

Saves the given cookie preferences to platform storage.

preferences should be a map of cookie types to their consent status.

Implementation

@override
Future<void> saveCookiePreferences(Map<String, dynamic> preferences) async {
  try {
    final storage = html.window.localStorage;

    try {
      final jsonString = const JsonEncoder().convert(preferences);
      storage[_storageKey] = jsonString;
    } on Exception catch (e) {
      debugPrint('Error converting preferences to JSON: $e');
      rethrow;
    }
  } on Exception catch (e) {
    debugPrint('Error saving cookie preferences: $e');
    rethrow;
  }
}