readValue method

Future<String?> readValue(
  1. String key
)

Implementation

Future<String?> readValue(String key) async {
  try {
    final items = await reader.getValues();
    final index = items.indexWhere((element) => element.name == key);
    if (index == -1) return null;
    final enabled = items[index].state ?? false;
    if (!enabled) return null;
    return items[index].value;
  } catch (err) {
    throw Exception("La lectura de la variable $key fallo");
  }
}