convert method

  1. @override
String convert(
  1. Map<String, dynamic> input
)
override

Converts the input map into a query string.

  • If the input map is empty, returns an empty string.
  • First, converts everything to a "plain" map of String -> String or String -> List, etc.
  • Then produces the final query string by encoding each key and value.

Implementation

@override
String convert(Map<String, dynamic> input) {
  if (input.isEmpty) return '';

  // First, convert everything to a "plain" map of String->String or String->List, etc
  final flattenedMap = _toEncodable(input) as Map<String, dynamic>;

  // Then produce the final query string
  return flattenedMap.entries
      .map((entry) {
        final key = Uri.encodeComponent(entry.key);
        final value = _encodeValue(entry.value);
        return '$key=$value';
      })
      .join('&');
}