getValueWidget method

Widget getValueWidget(
  1. MapEntry<String, dynamic> entry
)

Implementation

Widget getValueWidget(MapEntry<String, dynamic> entry) {
  final value = entry.value;
  return switch (value) {
    null => const Expanded(
        child: Text('undefined', style: TextStyle(color: Colors.grey)),
      ),
    num _ => Expanded(
        child: Text(
          value.toString(),
          style: const TextStyle(color: Colors.teal),
        ),
      ),
    String _ => Expanded(
        child: Text(
          '"$value"',
          style: const TextStyle(color: Colors.redAccent),
        ),
      ),
    bool _ => Expanded(
        child: Text(
          value.toString(),
          style: const TextStyle(color: Colors.purple),
        ),
      ),
    List<dynamic> _ when value.isEmpty => const Text(
        'Array[0]',
        style: TextStyle(color: Colors.black54),
      ),
    List<dynamic> _ => InkWell(
        onTap: () => _toggleOpenFlag(entry.key),
        child: Text(
          'Array<${getTypeName(value[0])}>[${value.length}]',
          style: const TextStyle(color: Colors.black54),
        ),
      ),
    _ => InkWell(
        onTap: () => _toggleOpenFlag(entry.key),
        child: const Text('Object', style: TextStyle(color: Colors.black54)),
      ),
  };
}