setViewAttributes abstract method

void setViewAttributes(
  1. Map<String, Object?> attributes
)

Sets multiple attributes in the current view rendering context.

This method allows view components or controllers to provide a batch of key-value pairs that can be accessed during the rendering of views. These attributes are typically used to pass data from the controller layer to the view layer (e.g., templates, partials, or components).

Parameters

  • attributes: A Map containing attribute names as keys and their corresponding values. Values may be null.

Usage

context.setViewAttributes({
  "title": "User Profile",
  "currentUser": currentUser,
  "showBanner": true,
});

Notes

  • Existing attributes with the same keys may be overwritten.
  • Implementations of ViewContext typically merge these attributes with other context data (headers, query params, session data) for template rendering.
  • Attributes are request-scoped and should not be shared across requests.

Implementation

void setViewAttributes(Map<String, Object?> attributes);