writePreferences static method

Future<void> writePreferences(
  1. SharedPreferencesPlusOptions options,
  2. Map<String, Object?> preferences
)

Implementation

static Future<void> writePreferences(
  SharedPreferencesPlusOptions options,
  Map<String, Object?> preferences,
) async {
  final file = await _getDbFile(options);
  if (file == null) {
    throw Exception('Failed to get database file');
  }
  if (!file.existsSync()) {
    await file.create(recursive: true);
  }
  await file.writeAsString(jsonEncode(preferences));
}