list<T> static method

PersistroLightro<List<T>> list<T>(
  1. String key, {
  2. required List<T> initial,
  3. required T fromJson(
    1. dynamic
    ),
  4. bool autoSave = true,
})

Creates a persistent list state container.

Implementation

static PersistroLightro<List<T>> list<T>(
  String key, {
  required List<T> initial,
  required T Function(dynamic) fromJson,
  bool autoSave = true,
}) {
  return PersistroLightro<List<T>>(
    key: key,
    initial: initial,
    decoder: (json) => List<T>.from(
      jsonDecode(json).map((x) => fromJson(x)),
    ),
    encoder: (value) => jsonEncode(value),
    autoSave: autoSave,
  );
}