CookieManager class

Wraps Dio's PersistCookieJar with helper methods and event emission.

Cookies set by the backend are handled automatically via the Dio interceptor. Use the methods here when the app needs to inspect or clear cookies manually e.g. after logout or to validate login cookies were received.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

Static Properties

interceptor → CookieManager
The Dio interceptor — attach to the Dio instance in ApiClient.
no setter

Static Methods

all() Future<List<Cookie>>
Get all cookies for the base URL.
clearAll() Future<void>
Clear all cookies for the base URL. Emits CookieEvents.onCookiesCleared.
clearByName(String name) Future<void>
Clear a specific cookie by name. Emits CookieEvents.onCookieChanged with an empty value.
get(String name) Future<Cookie?>
Get a single cookie by name. Returns null if not found.
getValue(String name) Future<String?>
Get a cookie's value by name. Returns null if not found.
has(String name) Future<bool>
Returns true if a cookie with name exists and has a non-empty value.
init(String baseUrl) Future<void>
Internal — called by Server.init.
set(Cookie cookie) Future<void>
Manually set a cookie — useful for app-side cookie injection. Emits CookieEvents.onCookieChanged.
setValue(String name, String value) Future<void>
Convenience: set a cookie by name and value.