brix_bloc library
Cubits for brix flows. They hold no auth logic and no Flutter objects: only immutable state that a screen shows, and methods it calls.
Classes
-
AccountProvider<
TUser, TProfileUpdate> -
The backend for a logged-in user's own account: current user, profile,
avatar, password, deletion. Kept apart from
AuthProvider, so an app writes only the parts it has. - AuthCapabilities
- What the backend's auth flow looks like. The flows pick the next screen from this instead of checking which backend is used.
-
AuthCodeEntryFlow<
TUser> - A CodeEntryFlow whose codes come from an AuthProvider (signup code, password reset).
- AuthFeedback
- Shows the auth flows' results in the app's own alert style.
-
AuthFormFlow<
TUser> - A FormFlow talking to an AuthProvider.
- AuthFormState
- State of a form screen (login, forgot password, signup, change password...).
- Opens the app's screens for the auth flows, so brix never knows route names or the navigation library.
-
AuthProvider<
TSignup, TUser> - The backend behind the auth flows. Each app writes one subclass for its backend (REST, Firebase, Supabase, ...).
-
AuthSession<
TUser> - A logged-in user and the tokens the backend gave for them.
-
AuthSessionStore<
TUser> - Where the app keeps the session between launches. Each app writes one subclass on its own storage.
- AuthWarning
- A local problem the flows report before any backend call, with a plain English message the app can show as it is.
- AvatarUpload
-
A picture for
AccountProvider.uploadAvatar: a file path (mobile) or the bytes (web, memory), plus its name and type. - BrixChangePasswordCubit
- Cubit for a change password screen, built on brix ChangePasswordFlow: current, new and confirm with show / hide and the new password's unmet rules in the state. Check the form, then call submit.
- BrixChangePasswordState
- What a change password screen shows: the three typed passwords, show / hide for each, the new password's unmet rules and the loader.
- BrixDeleteAccountCubit
- Cubit for a delete account screen, built on brix DeleteAccountFlow. The state is the flow's own CodeEntryState.
-
BrixFlow<
S> -
Base of every brix flow: holds one immutable state
Sand tells listeners when it changes. - BrixForgotPasswordCubit
- Cubit for a "forgot password" screen, built on brix ForgotPasswordFlow: send what is typed with identifierChanged, check the form, then call submit.
- BrixForgotPasswordState
- What a "forgot password" screen shows: the typed email and the loader.
- BrixLogger
- A readable console log for apps, one box per message, so lines that come one after another never run together:
-
BrixLoginCubit<
TUser> - Cubit for a login screen, built on brix LoginFlow. It holds no Flutter objects: the screen sends what is typed (identifierChanged, passwordChanged), checks its form, then calls login.
- BrixLoginState
- What a login screen shows: the typed email and password, "remember me", whether the password is hidden, and the loader.
-
BrixOtpCubit<
TUser> - Cubit for the signup code screen, built on brix OtpVerificationFlow. The state is the flow's own CodeEntryState. It starts at once.
-
BrixProfileCubit<
TUser, TProfileUpdate> - Cubit for a profile screen, built on brix ProfileFlow. The state is the flow's own ProfileState; it loads on start.
- BrixResetPasswordCubit
- Cubit for the "new password" screen, built on brix ResetPasswordFlow: the code part, the new password with its unmet rules, resend and "change email". It starts at once; opened without an email, it goes back to login.
- BrixResetPasswordState
- What the "new password" screen shows: the code part, the typed new password, its visibility and the rules it does not meet yet.
-
BrixSessionCubit<
TUser> -
Cubit for the session actions, built on brix SessionFlow: start on
the splash screen, logout from a logout button (
isLoggingOutfor its loader). The flow is disposed when the cubit closes. -
BrixSignupCubit<
TSignup, TUser> - Cubit for a signup screen, built on brix SignupFlow: email, password and confirm with show / hide and the unmet password rules in the state.
- BrixSignupState
- What a signup screen shows: the typed email and passwords, show / hide for both password fields, the rules the password does not meet yet and the loader.
- ChangePasswordFlow
- The change password screen of a logged-in user. The user stays logged in on this device; ending other sessions is the backend's job.
- CodeEntryFlow
-
Base of the code screens: one submit at a time, a rejected code counted
in CodeEntryState.failedAttempts, "resend" after a
ResendCooldown, and the countdown stopped on dispose. Subclasses say how long a code is, how a code is sent and how errors map. - CodeEntryState
- State of a screen where the user types an emailed code (signup code, password reset).
- DeleteAccountFlow
- Deleting the logged-in user's account, as the backend's AccountDeletionMode says. On success everything the store keeps is cleared ("remember me" too, the account is gone) and login opens.
-
Failed<
T> - The call did not work; failure says why.
- Failure
- Why something did not work. Every block (auth, network, account, ...) reports problems with these classes instead of plain strings, so an app can react to the kind of problem, not only show a text.
- ForgotPasswordFlow
- The "forgot password" screen: asks the backend to send a reset code or link, then moves on as AuthCapabilities.resetMode says.
- FormFlow
- Base of the form flows: one call at a time, busy state while it runs, and thrown errors shown as a failure instead of crashing.
- Json
- A safe way to read decoded JSON (from any backend: REST, Firebase, Supabase, ...) into your own models.
-
LoginFlow<
TUser> - Everything the login screen does, without any UI or state library.
- NetworkFailure
- No connection or the request timed out.
- OtpCodeBoxes
- The text fields of a code entered one digit per box. Used by every code screen controller, so typing, paste and clearing behave the same.
- OtpPurpose
- Why a one-time code was sent.
-
OtpVerificationFlow<
TUser> - The code screen after signup: verify the emailed code, ask for a new one after a cooldown, or go back to change the email.
- PasswordPolicy
- What a new password must contain (signup, reset, change password).
- PasswordRule
- One requirement of a PasswordPolicy, for a live checklist on screen.
-
ProfileFlow<
TUser, TProfileUpdate> - The logged-in user's profile: load, save the app's typed update, new avatar. After a save or an avatar the user is reloaded, and the saved session gets the fresh user.
-
ProfileState<
TUser> - State of the profile screen.
- RememberedCredentials
- Login details kept for "remember me".
- ResetPasswordFlow
- The "new password" screen of ResetMode.otp: the emailed code plus a new password, a new code after a cooldown, or back to change the email.
-
Result<
T> - Outcome of any brix call: Success or Failed, nothing else.
- ServerFailure
- The server failed or answered with an unexpected status.
-
SessionFlow<
TUser> - Starts and ends the user's session: what opens when the app starts, and logout.
- SessionState
- State of the session actions.
-
SignupFlow<
TSignup, TUser> -
The signup screen. The app builds its own typed body (
TSignup); the flow checks the password, sends it once, then opens the code screen (when the backend sends one) or login. -
Success<
T> -
The call worked. For calls without data use
Success<void>(null). - Not logged in or the session ended (HTTP 401).
- UnknownFailure
- Anything else. cause keeps the original error for logging; it is never meant to be shown to the user.
- UnsupportedFailure
- The backend does not offer this call (e.g. OTP on a link-only backend).
- ValidationFailure
- The input was rejected (HTTP 400 / 422, form rules on the server).
Enums
- AccountDeletionMode
- How the backend confirms that the user really wants their account gone.
- LogLevel
- How important a log line is. Lines below BrixLogger.minLevel are skipped.
- ResetMode
- How a backend lets the user set a new password.
Extensions
- BrixDeleteAccountCodeState on CodeEntryState
- What a delete account screen shows while the first code is asked for.
Functions
-
failureFromError(
Object error, StackTrace stackTrace) → Failure - Default way to turn a thrown error into a Failure.
-
maskIdentifier(
String identifier) → String - Hides most of an email or phone number for display, e.g. on the code screen ("code sent to ru•••@gmail.com").