formData method

Map<String, String> formData()

Parses the request body as URL-encoded form data (application/x-www-form-urlencoded).

Returns an empty map if the body is empty. Throws StateError if this request is a streaming request.

Example

final fields = request.formData();
final username = fields['username'];

Implementation

Map<String, String> formData() {
  final str = text();
  if (str.trim().isEmpty) return {};
  return Uri.splitQueryString(str);
}