addSensie method

Future<void> addSensie({
  1. required dynamic sensie,
})

Implementation

Future<void> addSensie({required dynamic sensie}) async {
  try {
    final prefs = await SharedPreferences.getInstance();
    final sensiesJson = prefs.getString(SENSIES);

    List<dynamic> sensies =
        sensiesJson != null ? jsonDecode(sensiesJson) : [];
    sensies.add(sensie);

    await prefs.setString(SENSIES, jsonEncode(sensies));
  } catch (e) {
    debugPrint('Error: $e');
  }
}