Skip to content
pubscout

keycloak_wrapper

1.5.1, released 2 months ago by fafifi.is-a.dev

Keycloak Single Sign-On authentication package for Flutter.

$ flutter pub add keycloak_wrapper
Source repository

What it does

Integrates Keycloak Single Sign-On (SSO) authentication into Flutter apps using OAuth 2.0 and OpenID Connect. Manages tokens automatically under the hood and provides a user authentication state stream.

AI-written summary of version 1.5.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to authenticate users via Keycloak in your Flutter application.
  • You want automatic token management and secure token storage using Keychain or Keystore.

Skip it when

  • You are using Firebase or Supabase authentication instead of Keycloak.
  • You need automated tests for the authentication flow, which are unsupported due to the webview login requirement.

Strengths

  • Provides an authentication state stream to keep the app in sync with login status changes.
  • Automatically manages and securely stores tokens under the hood.
  • Supports custom iOS/macOS web authentication session settings.

Weaknesses

  • All test files were removed because users must log in via the webview, making it untestable.
  • Requires native configuration adjustments on Android, iOS, and macOS.

Setup

Kind
Flutter widgets
Effort
Medium
Code generation
No
Direct dependencies
3

Requires adding a valid redirect URI in the Keycloak console, setting up custom schemes in Android build.gradle (manifestPlaceholders) and iOS/macOS Info.plist, and removing android:taskAffinity='' from AndroidManifest.xml if using Flutter v3.22.0 or newer.

final keycloakWrapper = KeycloakWrapper();

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  keycloakWrapper.initialize(
    config: KeycloakConfig(
      bundleIdentifier: '<bundle_identifier>',
      clientId: '<client_id>',
      frontendUrl: '<frontend_url>',
      realm: '<realm>',
    ),
  );
  runApp(const MyApp());
}

Alternatives

Packages that do the same job and could replace keycloak_wrapper.

Works with

Packages commonly used together with keycloak_wrapper: ones it builds on, ones built on it, and its own family.