getIntList method

List<int> getIntList(
  1. String key,
  2. List<int> def
)

Implementation

List<int> getIntList(String key, List<int> def)
{
    try
    {
        if (_sharedPreferences.containsKey(key) == false)
            return def;

        List<String>? stringList = _sharedPreferences.getStringList(key);
        if (stringList == null)
            return def;

        var intList = List<int>.empty();
        for (String s in stringList)
            intList.add(int.parse(s));

        return intList;
    }
    catch (e)
    {
        logger.logInfo(e.toString());
        logger.logInfo('${_sharedPreferences.get(key)}');
        return def;
    }
}