flutter-auth-ui 📱
A simple library of predefined widgets to easily and quickly create auth components using Flutter and Supabase.
⚠️ Developer Preview: This is a developer preview and there maybe some breaking changes until we release v1.0.0.
Email Auth
Use a SupaEmailAuth widget to create an email and password signin/ signup form.
You can pass metadataFields to add additional fields to the signup form to pass as metadata to Supabase.
// Create a Signup form
SupaEmailAuth(
authAction: AuthAction.signUp,
redirectUrl: kIsWeb
? null
: 'io.supabase.flutter://reset-callback/'
onSuccess: (GotrueSessionResponse response) {
// do something, for example: navigate('home');
},
onError: (error) {
// do something, for example: navigate("wait_for_email");
},
metadataFields: [
MetaDataField(
prefixIcon: const Icon(Icons.person),
label: 'Username',
key: 'username',
validator: (val) {
if (val == null || val.isEmpty) {
return 'Please enter something';
}
return null;
},
),
],
)
// Create a Signin form
SupaEmailAuth(
authAction: AuthAction.signIn,
redirectUrl: kIsWeb
? null
: 'io.supabase.flutter://reset-callback/',
onSuccess: (GotrueSessionResponse response) {
// do something, for example: navigate('home');
},
onError: (error) {
// do something, for example: navigate("wait_for_email");
},
)
Magic Link Auth
Use SupaMagicAuth widget to create a magic link signIn form.
SupaMagicAuth(
redirectUrl: kIsWeb
? null
: 'io.supabase.flutter://reset-callback/',
onSuccess: (Session response) {
// do something, for example: navigate('home');
},
onError: (error) {
// do something, for example: navigate("wait_for_email");
},
)
Reset password
Use SupaResetPassword to create a password reset form.
SupaResetPassword(
accessToken: session.accessToken,
redirectUrl: kIsWeb
? null
: 'io.supabase.flutter://reset-callback/',
onSuccess: (GotrueUserResponse response) {
// do something, for example: navigate('home');
},
onError: (error) {
// do something, for example: navigate("wait_for_email");
},
)
Social Auth
Use SupaSocialsAuth to create list of social login buttons.
SupaSocialsAuth(
socialProviders: [
SocialProviders.apple,
SocialProviders.google,
],
colored: true,
redirectUrl: kIsWeb
? null
: 'io.supabase.flutter://reset-callback/',
onSuccess: (Session response) {
// do something, for example: navigate('home');
},
onError: (error) {
// do something, for example: navigate("wait_for_email");
},
)
Download Auth UI source code on GitHub
Supabase Auth UI library for Flutter
https://github.com/supabase-community/supabase_auth_ui
81 forks.
160 stars.
0 open issues.
Recent commits:
- chore(release): publish packages (#178)Prepared all packages to be released to pub.dev———Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>Co-authored-by: spydon <744771+spydon@users.noreply.github.com>, GitHub
- feat: add customizable SupaSocialsAuth spacing (#176)## Summary- add a public `spacing` parameter to `SupaSocialsAuth`- preserve the existing effective 16 px gap as the default- apply custom spacing to vertical buttons, icon buttons, and wrappedicon rows- cover default and custom spacing in widget testsFixes #175## Why`SupaSocialsAuth` previously encoded its gap as 8 px of vertical paddingon every button. That produced a fixed 16 px gap between adjacentbuttons and left consumers no way to match their design system withoutcopying the widget.The new parameter moves gap ownership to the parent `Column` or `Wrap`,while retaining the existing horizontal item padding.## ImpactExisting consumers keep the same effective inter-button spacing bydefault. Consumers can now set a custom gap for both social buttonvariants.## Validation- `dart format –output=none –set-exit-if-changed lib test example/lib`- `flutter test` (72 tests)- `flutter test –platform chrome` (72 tests)- Flutter 3.35.7 focused widget tests (7 tests)- strict analyzer run; only pre-existing upstream diagnostics remainCo-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>, GitHub
- fix: resolve all flutter analyze and dcm analyze issues (#177)## WhatFixes every issue reported by `flutter analyze` and `dcm analyze` acrossthe library, example app, and tests. Both now report **no issues**, andthe full test suite (69 tests) still passes.## Changes**Library (`lib/src/components/`)**- `supa_socials_auth.dart` — remove banned `dart:io` import in favor of`defaultTargetPlatform`; combine duplicate switch cases(`linkedin`/`linkedinOidc`, `slack`/`slackOidc`) and replace theredundant `OAuthProvider()` catch-all with `_`; use null-aware mapelements; drop unnecessary `.call`; add `semanticLabel` to provider logoimages; wrap async callbacks and the discarded `cancel()` in`unawaited`.- `supa_email_auth.dart` — make `MetaDataField` const; dispose`_emailFocusNode`; use null-aware spread (`…?`); remove unnecessarysingle-element collection spreads; drop unnecessary `.call`s; remove aredundant `late`.- `supa_verify_phone.dart` — type the raw `Map`; extract the asyncbutton handler into a method wrapped with `unawaited`.- `supa_magic_auth.dart`, `supa_phone_auth.dart`,`supa_reset_password.dart` — wrap async callbacks passed tosync-expecting params in `unawaited`; remove an unnecessary `.call`.**Example (`example/lib/`)**- Wrap discarded `Navigator`/`signOut` futures in `unawaited`.- Convert `sign_in.dart` and `sign_in_prefilled.dart` to`StatefulWidget` so `TapGestureRecognizer`s are stored as fields anddisposed.**Test**- `test/test_utils.dart` — use a null-aware map element.## Testing- `flutter analyze` — no issues- `dcm analyze` — no issues- `flutter test` — 69 passing, GitHub
- feat!: use idiomatic Flutter l10n via gen-l10n (#174)## WhatReplaces the package's custom, constructor-based localization with theidiomatic Flutter `flutter gen-l10n` mechanism.Previously every widget took a `localization:` parameter holding one ofsix hand-written `SupaXxxLocalization` classes with English stringdefaults. There was no `LocalizationsDelegate`, no locale resolution, noARB files, and shared strings (`signIn`, `unexpectedError`, …) wereduplicated across all six classes.Now strings come from a single generated `SupabaseAuthUILocalizations`class + delegate, resolved from `BuildContext` / the active locale.## Changes- Add `l10n.yaml` + a consolidated English ARB(`lib/src/l10n/supabase_auth_ui_localizations_en.arb`); commit thegenerated output under `lib/src/l10n/generated/`.- Add `flutter_localizations` and `intl` dependencies; set `flutter:generate: true`.- All six components read strings via a `context.l10n` extension(`lib/src/l10n/l10n_extension.dart`) that falls back to English when nodelegate is registered.- Provider button labels move from`SupaSocialsAuthLocalization.oAuthButtonLabels` to an`oAuthButtonLabels` parameter on `SupaSocialsAuth`; the "Continue withX" prefix is now a localized placeholder message.- Remove the six `SupaXxxLocalization` classes and the per-widget`localization:` parameters.- Example app registers`SupabaseAuthUILocalizations.localizationsDelegates` /`supportedLocales`.- README documents registering the delegate and overriding strings via acustom delegate subclass.## Breaking changeThe `localization:` parameters and the `SupaEmailAuthLocalization`,`SupaMagicAuthLocalization`, `SupaPhoneAuthLocalization`,`SupaResetPasswordLocalization`, `SupaSocialsAuthLocalization`, and`SupaVerifyPhoneLocalization` classes are removed. Consumers register`SupabaseAuthUILocalizations.delegate` and provide a custom delegate totranslate or override strings.The verify-phone screen's `"Unexpected error has occurred"` is foldedinto the shared `unexpectedError` (`"An unexpected error occurred"`)during the consolidation.## Verification- `flutter analyze –fatal-warnings –fatal-infos lib test example/lib`— clean- `flutter test` — 69 tests pass- `dart format` — clean, GitHub
- test: add full test suite for auth UI components (#173)## WhatReplaces the placeholder test with a full unit and widget test suite (72tests) covering every component, localization, and utility in thepackage.## Test harnessA shared harness (`test/test_utils.dart`) wires a `MockClient` into`Supabase.initialize` so the widgets can be exercised without any realnetwork or platform plugins:- Records every request and lets each test swap in a responder (successsession, user-only, or error).- Uses `EmptyLocalStorage`, an in-memory PKCE store, and`detectSessionInUri: false` so no plugins are touched.- Helpers for route arguments (`SupaVerifyPhone`), establishing/clearinga session, and building responses.## Coverage- **Utilities**: `defaultPasswordValidator`, `handleAuthError`, snackbarextensions, `spacer`, `SupaAuthAction`.- **Localizations**: defaults and overrides for all six localizationclasses.- **Metadata fields**: `MetaDataField` / `BooleanMetaDataField`(defaults, assertion, rich/plain label rendering).- **Components**: `SupaEmailAuth` (rendering, validation, sign in/up,metadata, required-checkbox gating, password recovery + OTP flows),`SupaMagicAuth`, `SupaResetPassword`, `SupaPhoneAuth`,`SupaVerifyPhone`, `SupaSocialsAuth`, `SupaPasswordField`.## Other- Added `http` to `dev_dependencies` (used by the harness).- Added `test` to the melos `analyze` script so test code is linted inCI.All tests pass and `flutter analyze –fatal-warnings –fatal-infos` and`dart format` are clean., GitHub
Provides the list of the opensource Flutter apps collection with GitHub repository.