convert method

  1. @override
String convert(
  1. Object? input
)
override

Converts input and returns the result of the conversion.

Implementation

@override
String convert(Object? input) {
  if (explode) {
    throw UnimplementedError();
  }

  switch (input) {
    case Map():
      return input.entries.map((entry) => '${entry.key},${convert(entry.value)}').join(',');
    case List():
      return input.map(convert).join(',');

    default:
      if (input is String) {
        return input;
      }
      if (input == null) {
        return '';
      }

      // For primitives `toString` should result in the same.
      // Using the json codec to align with the decode converter.
      return jsonEncode(input);
  }
}