API reference
The public surface of
thunderid_flutter, as documented in its reference pages.SignIn`SignIn` is a pre-built Flutter widget that drives the full sign-in loop using the ThunderID Flow Execution API. It renders the appropriate input form for each authentication step (username/password, TOTP, email OTP, etc.) and automatically advances through the flow until completion. ```dart import 'package:thunderid_flutter/thunderid_flutter.dart'; SignIn( applicationId: '', onComplete: () { // Refresh state after sign-in ThunderIDProvider.of(context).refresh(); }, onError: (error) => print('Sign in failed: $error'), ) ```
import 'package:thunderid_flutter/thunderid_flutter.dart';
SignIn(
applicationId: '<your-application-id>',
onComplete: () {
// Refresh state after sign-in
ThunderIDProvider.of(context).refresh();
},
onError: (error) => print('Sign in failed: $error'),
)SignInButton`SignInButton` is a pre-styled `ElevatedButton` widget that triggers your sign-in flow when tapped. ```dart import 'package:thunderid_flutter/thunderid_flutter.dart'; SignInButton( onTap: () { // Navigate to your sign-in screen Navigator.of(context).push( MaterialPageRoute(builder: (_) => const AuthScreen()), ); }, ) ```
onTaprequiredVoidCallbackCalled when the button is tapped. Implement your navigation or sign-in logic here.
labelString?Override the button label. Defaults to the localized `"Sign In"` string.
styleButtonStyle?Override the `ElevatedButton` style.
import 'package:thunderid_flutter/thunderid_flutter.dart';
SignInButton(
onTap: () {
// Navigate to your sign-in screen
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const AuthScreen()),
);
},
)SignOutButton`SignOutButton` is a pre-styled `OutlinedButton` widget that calls `signOut()` on tap and notifies the parent `ThunderIDProvider` to refresh auth state. ```dart import 'package:thunderid_flutter/thunderid_flutter.dart'; SignOutButton( onSignOutComplete: () { // Optional: navigate or show a confirmation after sign-out }, ) ```
onSignOutCompleteVoidCallback?Called after sign-out completes and the provider state is refreshed.
labelString?Override the button label. Defaults to the localized `"Sign Out"` string.
styleButtonStyle?Override the `OutlinedButton` style.
import 'package:thunderid_flutter/thunderid_flutter.dart';
SignOutButton(
onSignOutComplete: () {
// Optional: navigate or show a confirmation after sign-out
},
)SignUp`SignUp` is a pre-built Flutter widget that drives the full registration flow using the ThunderID Flow Execution API. It renders each registration step as it arrives and advances through the flow until the account is created and the user is signed in. ```dart import 'package:thunderid_flutter/thunderid_flutter.dart'; SignUp( applicationId: '', onComplete: () { ThunderIDProvider.of(context).refresh(); }, onError: (error) => print('Sign up failed: $error'), ) ```
import 'package:thunderid_flutter/thunderid_flutter.dart';
SignUp(
applicationId: '<your-application-id>',
onComplete: () {
ThunderIDProvider.of(context).refresh();
},
onError: (error) => print('Sign up failed: $error'),
)SignedIn`SignedIn` is a guard widget that renders its `child` only when the user is authenticated. When the user is not signed in it renders `fallback` instead (or nothing, if no fallback is provided). This widget re-renders automatically whenever the auth state in the parent `ThunderIDProvider` changes.
childrequiredWidgetRendered when `ThunderIDProvider.of(context).isSignedIn` is `true`.
fallbackWidget?Rendered when the user is not signed in. Defaults to `const SizedBox.shrink()` if omitted.
import 'package:thunderid_flutter/thunderid_flutter.dart'; SignedIn( child: const HomeScreen(), fallback: const AuthScreen(), )
SignedOut`SignedOut` is a guard widget that renders its `child` only when the user is **not** authenticated. When the user is signed in it renders `fallback` instead (or nothing, if no fallback is provided). This widget re-renders automatically whenever the auth state in the parent `ThunderIDProvider` changes.
childrequiredWidgetRendered when `ThunderIDProvider.of(context).isSignedIn` is `false`.
fallbackWidget?Rendered when the user is signed in. Defaults to `const SizedBox.shrink()` if omitted.
import 'package:thunderid_flutter/thunderid_flutter.dart'; SignedOut( child: const AuthScreen(), fallback: const HomeScreen(), )
UserProfile`UserProfile` is a pre-built form widget for viewing and editing the authenticated user's profile. It loads the user's profile from `/scim2/Me` on mount, renders editable fields, and saves changes via `updateUserProfile`. ```dart import 'package:thunderid_flutter/thunderid_flutter.dart'; UserProfile( onSaved: (updatedUser) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Profile updated')), ); }, onError: (error) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Failed to update: $error')), ); }, ) ```
import 'package:thunderid_flutter/thunderid_flutter.dart';
UserProfile(
onSaved: (updatedUser) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Profile updated')),
);
},
onError: (error) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Failed to update: $error')),
);
},
)Configuration`ThunderIDConfig` is the configuration class passed to `ThunderIDProvider` and to `ThunderIDClient.initialize()`.
baseUrlString**Required.** Your ThunderID instance URL. Must use HTTPS (e.g., `https://localhost:8090`).
clientIdString?The Client ID from your ThunderID application. Required for redirect-based authentication and token operations.
scopesListOAuth 2.0 scopes to request. Include `'profile'` and `'email'` to receive user identity claims.
afterSignInUrlString?The redirect URI to return to after sign-in. Must match an **Allowed Redirect URI** registered in the console.
afterSignOutUrlString?The redirect URI to return to after sign-out. Must match an **Allowed Post-Logout Redirect URI** in the console.
signInUrlString?Override the sign-in URL. Defaults to the ThunderID hosted sign-in page.
signUpUrlString?Override the sign-up URL.
applicationIdString?The Application ID used for app-native (embedded) sign-in flows via the Flow Execution API.
organizationHandleString?The organization handle for multi-tenant deployments.
tokenValidationTokenValidationConfig?Controls ID token validation behavior.
preferencesThunderIDPreferences?UI theme and localization preferences.
import 'package:thunderid_flutter/thunderid_flutter.dart'; final config = ThunderIDConfig( baseUrl: 'https://localhost:8090', clientId: '<your-client-id>', scopes: const ['openid', 'profile', 'email'], afterSignInUrl: 'dev.thunderid.app://callback', afterSignOutUrl: 'dev.thunderid.app://logout', applicationId: '<your-application-id>', );
ThunderIDClient`ThunderIDClient` is the core authentication client in the `thunderid_flutter` package. It manages the full authentication lifecycle: initialization, sign-in (both app-native and redirect-based), session, token management, and user profile operations. All protocol operations are delegated to the native ThunderID iOS and Android SDKs via Flutter platform channels. When you use `ThunderIDProvider`, a `ThunderIDClient` instance is created and managed automatically. Access it via `ThunderIDProvider.of(context).client` from any widget.
import 'package:thunderid_flutter/thunderid_flutter.dart';
// Access via ThunderIDProvider (recommended)
final thunder = ThunderIDProvider.of(context);
final token = await thunder.client.getAccessToken();
// Or create directly (advanced)
final client = ThunderIDClient();
await client.initialize(
config: ThunderIDConfig(
baseUrl: 'https://localhost:8090',
clientId: '<your-client-id>',
scopes: const ['openid', 'profile', 'email'],
),
);ThunderIDState`ThunderIDState` is the reactive authentication state object provided by `ThunderIDProvider`. It holds the current user, loading state, and initialization status, and exposes the underlying `ThunderIDClient` for direct API calls. Access `ThunderIDState` from any widget using `ThunderIDProvider.of(context)`.
import 'package:flutter/material.dart';
import 'package:thunderid_flutter/thunderid_flutter.dart';
void main() {
runApp(
ThunderIDProvider(
config: ThunderIDConfig(
baseUrl: 'https://localhost:8090',
clientId: '<your-client-id>',
afterSignInUrl: 'dev.thunderid.app://callback',
afterSignOutUrl: 'dev.thunderid.app://logout',
),
child: const MyApp(),
),
);
}