getValueWidget method

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

Implementation

getValueWidget(MapEntry<String, dynamic> entry) {
  if (entry.value == null) {
    return const Expanded(
      child: SelectableText(
        'undefined',
        style: TextStyle(color: Colors.grey),
      ),
    );
  } else if (entry.value is int) {
    return Expanded(
      child: SelectableText(
        entry.value.toString(),
        style: const TextStyle(color: Color(0xff6491b3)),
      ),
    );
  } else if (entry.value is String) {
    return Expanded(
      child: SelectableText(
        "\"${entry.value}\"",
        style: const TextStyle(color: Color(0xff6a8759)),
      ),
    );
  } else if (entry.value is bool) {
    return Expanded(
      child: SelectableText(
        entry.value.toString(),
        style: const TextStyle(color: Color(0xffca7832)),
      ),
    );
  } else if (entry.value is double) {
    return Expanded(
      child: SelectableText(
        entry.value.toString(),
        style: const TextStyle(color: Color(0xff6491b3)),
      ),
    );
  } else if (entry.value is List) {
    if (entry.value.isEmpty) {
      return InkWell(
        onTap: () {
          setState(() {
            openFlag[entry.key] = !(openFlag[entry.key] ?? false);
          });
        },
        onDoubleTap: () {
          Clipboard.setData(ClipboardData(
            text: jsonEncode(entry.value),
          )).then((_) {
            ScaffoldMessenger.of(context).showSnackBar(const CustomSnackBar());
          });
        },
        child: const Text(
          'Array[0]',
          style: TextStyle(color: Colors.grey),
        ),
      );
    } else {
      return InkWell(
        onTap: () {
          setState(() {
            openFlag[entry.key] = !(openFlag[entry.key] ?? false);
          });
        },
        onDoubleTap: () {
          Clipboard.setData(ClipboardData(text: jsonEncode(entry.value))).then((_) {
            ScaffoldMessenger.of(context).showSnackBar(const CustomSnackBar());
          });
        },
        child: Text(
          'Array<${getTypeName(entry.value[0])}>[${entry.value.length}]',
          style: const TextStyle(color: Colors.grey),
        ),
      );
    }
  }
  return InkWell(
    onTap: () {
      setState(() {
        openFlag[entry.key] = !(openFlag[entry.key] ?? false);
      });
    },
    onDoubleTap: () {
      Clipboard.setData(ClipboardData(text: jsonEncode(entry.value))).then((_) {
        ScaffoldMessenger.of(context).showSnackBar(const CustomSnackBar());
      });
    },
    child: const Text(
      'Object',
      style: TextStyle(color: Colors.grey),
    ),
  );
}