innerCollapsibleList static method

List<Widget> innerCollapsibleList(
  1. List list,
  2. String text
)

Implementation

static List<Widget> innerCollapsibleList(List list, String text) {
  return list.mapIndexed((index, object) {
    // 1) grab the raw toJson() result…
    final raw = object.toJson();

    // 2) ensure it's a Map, casting away the `dynamic`
    if (raw is! Map) {
      throw ArgumentError('Expected toJson() to return a Map, got $raw');
    }
    final json = Map<String, dynamic>.from(raw);

    // 3) now you can safely do .entries.toList()
    final entries = json.entries.toList();

    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingXSmall),
      child: CollapsibleList(
        title: '$text #${index + 1}',
        collapsibleValues: info(entries).joinWithSeparator(
          const DottedSeparator(padding: EdgeInsets.symmetric(vertical: 8)),
        ),
      ),
    );
  }).toList();
}