fromFormConstructor function

ConstructorElement? fromFormConstructor(
  1. ClassElement cls
)

Returns the fromForm(Map<String, dynamic>) factory if cls exposes one. Used to decode form-urlencoded / multipart request bodies, with priority over fromJsonConstructor when both exist.

Implementation

ConstructorElement? fromFormConstructor(ClassElement cls) {
  for (final c in cls.constructors) {
    if (c.name != 'fromForm') continue;
    if (c.parameters.length != 1) continue;
    final t = c.parameters.first.type;
    if (t is InterfaceType && t.isDartCoreMap) return c;
  }
  return null;
}