FlashMessagingMiddleware class
Middleware that manages the lifecycle of flashed session state across requests.
This middleware is responsible for clearing temporary session data after it has survived the expected number of request cycles. In practice, this supports common redirect-and-render flows where flashed data needs to be available briefly and then removed.
Behavior:
- skips flash lifecycle handling for
/api/routes - checks the internal
_flashTripscounter in the container - clears flashed messages, errors, and old input after two trips
- advances the trip counter from
1to2when needed
Example:
router.get(
'/dashboard',
handler: (request) async => dashboardController.index(request),
middleware: [FlashMessaging.middleware],
);
Constructors
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 Methods
-
middleware(
HttpRequest request, Future< void> next()) → Future - Processes flash-message lifecycle state for the current request.