FormData class
A FormData instance returned from calling Request.formData on an incoming HTTP request.
A single form data entry can contain multiple StringValue or FileValue instances, which are used to represent the form data. A single data entry value is represented as a FormDataEntryValue instance, which allows for conditionally handling form data depending on the type:
Future<Response> post(Request request) async {
final formData = await request.formData();
final name = formData.get('name');
if (name != null) {
name.map(
file: (file) => print(file.filename),
string: (str) => print(str.value),
);
}
}
Constructors
-
FormData.new([Map<
String, List< ? params])FormDataEntryValue> >
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
keys
→ Iterable<
String> -
Returns all of the keys in the form data.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ Iterable<
List< FormDataEntryValue> > -
Returns the value of the given key.
no setter
Methods
-
get(
String key) → FormDataEntryValue? - Returns the first FormDataEntryValue instance for the given key, or null if the key does not exist.
-
getAll(
String key) → List< FormDataEntryValue> - Returns a list of FormDataEntryValue instances for the given key.
-
has(
String name) → bool - Returns whether the form data contains the given key.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String key) → List< FormDataEntryValue> ? - Gets a form data entry by name.