GitHubAuthController class

Controller for managing GitHub-based authentication flows.

This controller handles all the business logic for GitHub authentication, including sign-in and authentication event handling. It can be used with any UI implementation.

Example usage:

final controller = GitHubAuthController(
  client: client,
  onAuthenticated: () {
    // Do something when the user is authenticated.
    //
    // NOTE: You should not navigate to the home screen here, otherwise
    // the user will have to sign in again every time they open the app.
  },
);

// Initiate sign-in
await controller.signIn();

// Listen to state changes
controller.addListener(() {
  // UI will rebuild automatically
  // Can use `controller.state` to access the current state.
});
Inheritance

Constructors

GitHubAuthController({required ServerpodClientShared client, VoidCallback? onAuthenticated, dynamic onError(Object error)?, List<String> scopes = defaultScopes})
Creates a GitHub authentication controller.

Properties

client ServerpodClientShared
The Serverpod client instance.
final
error Object?
The current error, if any.
no setter
errorMessage String?
The current error message, if any.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isAuthenticated bool
Whether the user is authenticated.
no setter
isLoading bool
Whether the controller is currently processing a request.
no setter
onAuthenticated VoidCallback?
Callback when authentication is successful.
final
onError → dynamic Function(Object error)?
Callback when an error occurs during authentication.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scopes List<String>
Scopes to request from GitHub.
final
state GitHubAuthState
The current state of the authentication flow.
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
signIn() Future<void>
Initiates the GitHub Sign-In flow.
toString() String
A string representation of this object.
inherited

Operators

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

Constants

defaultScopes → const List<String>
Default scopes to request from GitHub.