saveModel static method

Future<void> saveModel(
  1. String table,
  2. Model model
)

Implementation

static Future<void> saveModel(String table, Model model) async {
  try {
    String key = 'database_table_$table';

    List<Map<String, dynamic>>? models = await getModels(table);

    if (models == null) {
      return;
    }

    List<String>? data = await compute(saveDatabaseModel, {
      'table': table,
      'model': model,
      'models': models,
    });

    if (data == null) {
      return;
    }

    await getSharedPreferences().setStringList(key, data);
  } catch (e) {
    print(e);
  }
}