Converts instance to a map.
Map<String, dynamic> toMap() { return { "currentIndex": currentIndex, "list": list?.map((e) => e.toMap()).toList(), }; }