getValueWidget static method

Widget getValueWidget(
  1. dynamic content
)

Determines the appropriate widget to display the value based on its type.

Implementation

static Widget getValueWidget(dynamic content) {
  // Determine the style based on the value's type.
  var style = TextStyle(color: Colors.red.shade800);
  if (content == null) {
    return Expanded(
      child: Text(
        'undefined',
        style: style,
      ),
    );
  } else if (content is int ||
      content is String ||
      content is bool ||
      content is double ||
      content is TomlLocalDate ||
      content is TomlLocalDateTime ||
      content is TomlDateTime) {
    return Expanded(
      child: Text(
        content.toString(),
        style: style,
      ),
    );
  } else if (content is List) {
    if (content.isEmpty) {
      return const Text(
        'Array[0]',
        style: TextStyle(color: Colors.grey),
      );
    } else {
      return Text(
        'Array of ${getTypeName(content)}[${content.length}]',
        style: const TextStyle(color: Colors.grey),
      );
    }
  }
  return const Text(
    'Table',
    style: TextStyle(color: Colors.grey),
  );
}