toUrl method

Uri toUrl()

Converts the current BaseModel to a Uri that can be used as a distinct identifier. The model must not be too large to avoid exceeding the maximum length of a URL.

Each field of toJson becomes one query parameter. Scalar values (strings, numbers, booleans) are written with toString(); lists and maps are JSON-encoded, so the generated fromUri / fromUriOrNull read them back unchanged.

Implementation

Uri toUrl() {
  return Uri(
    path: $className,
    queryParameters: toJson().mapValues(_toQueryValue),
  );
}