get function

String? get(
  1. String key
)

Get the value of the cookie with name key.

Implementation

String? get(String key) {
  final cookies = document.cookie?.split('; ') ?? [];
  for (var cookie in cookies) {
    var parts = cookie.split('=');
    var name = Uri.decodeComponent(parts[0]);
    if (key == name) {
      return parts[1].isNotEmpty ? Uri.decodeComponent(parts[1]) : null;
    }
  }
  return null;
}