MagicStarterOtpController class

Controller managing the phone OTP authentication flow.

The flow has two steps:

  1. sendOtp — POSTs the phone number to /auth/otp/send. On success, advances to OtpStep.codeInput and stores the phone for step 2.
  2. verifyOtp — POSTs phone + code to /auth/otp/verify. On success, concludes the sign-in through CompletesSignIn.completeSignIn.

Gated by MagicStarterConfig.hasPhoneOtpFeatures.

Inheritance

Constructors

MagicStarterOtpController()

Properties

firstError → String?
Get the first validation error message.
no setterinherited
hasErrors → bool
Check if there are any validation errors.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
initialized → bool
Whether the controller has been initialized.
no setterinherited
isDisposed → bool
Whether the controller has been disposed.
no setterinherited
isEmpty → bool
Check if empty (no data).
no setterinherited
isError → bool
Check if an error occurred.
no setterinherited
isLoading → bool
Check if currently loading.
no setterinherited
isSuccess → bool
Check if successfully loaded.
no setterinherited
phoneNumber → String?
Returns the phone number captured during sendOtp, or null if step 1 has not been completed yet.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
rxState → dynamic
Get the current state.
no setterinherited
rxStatus → RxStatus
Get the current status.
no setterinherited
step → OtpStep
Returns the current OTP flow step.
no setter
validationErrors ↔ Map<String, String>
Current validation errors keyed by field name.
getter/setter pairinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
authorize(String ability, [Object? arguments]) → void
Authorize an action against the current Auth.user via the Gate.
inherited
clearErrors() → void
Clear all validation errors.
inherited
clearFieldError(String field) → void
Clear a specific field's validation error.
inherited
completeSignIn(Map<String, dynamic>? body) → Future<bool>
Concludes a sign-in from the backend's response body.
inherited
dispose() → void
Runs onClose if it has not run yet, then releases the notifier.
inherited
errorFieldFor(String wireKey) → String
Map a raw wire validation key to the form field it should report on.
inherited
fetchList<E>(String url, E fromMap(Map<String, dynamic>), {String dataKey = 'data', Map<String, dynamic>? query, Map<String, String>? headers}) → Future<void>
Fetch a list of resources and auto-manage loading/success/error/empty states.
inherited
fetchOne(String url, dynamic fromMap(Map<String, dynamic>), {String dataKey = 'data', Map<String, dynamic>? query, Map<String, String>? headers}) → Future<void>
Fetch a single resource and auto-manage loading/success/error states.
inherited
getError(String field) → String?
Get the validation error message for a field.
inherited
handleApiError(MagicResponse response, {String? fallback}) → void
Handle API error response automatically.
inherited
hasError(String field) → bool
Check if a field has a validation error.
inherited
Navigate to wherever a signed-in user should land after authenticating.
inherited
Navigate to path when a navigator context is available.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
onClose() → void
Called when the controller is about to be disposed.
inherited
onInit() → void
Called when the controller is first created.
inherited
otpVerify() → Widget
Render OTP verify view via registry key.
refreshUI() → void
Refresh the UI by notifying listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
renderState(Widget onSuccess(dynamic state), {Widget? onLoading, Widget onError(String message)?, Widget? onEmpty}) → Widget
Render UI based on current status.
inherited
resetToPhoneInput() → void
Resets the flow back to OtpStep.phoneInput.
sendOtp({required String phone}) → Future<void>
Sends an OTP code to phone via POST /auth/otp/send.
setEmpty() → void
Set empty state (no data).
inherited
setError(String message) → void
Set error state with message.
inherited
setErrorsFromMap(Map<String, List<String>> errors) → void
Set validation errors from a raw wire error map, keyed by errorFieldFor.
inherited
setErrorsFromResponse(MagicResponse response) → void
Set validation errors from an API response.
inherited
setLoading() → void
Set loading state.
inherited
setState(dynamic newState, {RxStatus? status, bool notify = true}) → void
Update state and/or status.
inherited
setSuccess(dynamic data) → void
Set success state with data.
inherited
toString() → String
A string representation of this object.
inherited
validate(Map<String, dynamic> data, Map<String, List<Rule>> rules) → Map<String, dynamic>
Validate the given data against the rules.
inherited
validateRequest(FormRequest request, Map<String, dynamic> data) → Map<String, dynamic>
Run a FormRequest through this mixin's error bag instead of FormRequest.validate().
inherited
validateRequestAsync(FormRequest request, Map<String, dynamic> data) → Future<Map<String, dynamic>>
Same contract as validateRequest, but validates through Validator.validateAsync so any AsyncRule in request's rules actually runs.
inherited
verifyOtp({required String phone, required String code}) → Future<void>
Verifies the OTP code for phone via POST /auth/otp/verify.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

instance → MagicStarterOtpController
Singleton accessor via IoC container.
no setter