cookie method

Cookie? cookie(
  1. String name
)

Get a specific cookie by name from the response.

Searches through all Set-Cookie headers for a cookie with the given name. Returns the first matching cookie or null if not found.

Example:

final sessionCookie = response.cookie('session_id');
expect(sessionCookie?.value, 'abc123');
expect(sessionCookie?.httpOnly, true);

name The name of the cookie to find. Returns the Cookie object or null if not found.

Implementation

Cookie? cookie(String name) {
  return cookies.where((c) => c.name == name).firstOrNull;
}