Skip to content

Latest commit

 

History

History
105 lines (71 loc) · 2.61 KB

README.md

File metadata and controls

105 lines (71 loc) · 2.61 KB


Logto helps you quickly focus on everything after signing in.

Logto Flutter SDK

Build Status

This project is the official Flutter SDK for Logto. It provides a simple way to integrate Logto into your Flutter project.

In the background, this SDK uses the flutter_web_auth_2 package to handle the OAuth2 flow.

Installation

Add the following dependencies to your pubspec.yaml file:

dependencies:
  logto_dart_sdk: ^3.0.0

Then run flutter pub get to install the package.

Or directly install the package by running:

flutter pub add logto_dart_sdk

Check out the package on pub.dev.

Setup

Learn more about the flutter_web_auth_2 setup.

Usages

Init Logto SDK

  final logtoConfig = const LogtoConfig(
    endpoint: "<your-logto-endpoint>",
    appId: "<your-app-id>"
  );

  void _init() {
    logtoClient = LogtoClient(
      config: logtoConfig,
      httpClient: http.Client(), // Optional http client
    );
    render();
  }

Sign in and sign out

  // Sign in
  await logtoClient.signIn(redirectUri);

  // Sign out
  await logtoClient.signOut(redirectUri);

Full SDK documentation

Check Flutter SDK guide for more details.

Supported platforms

iOS, Android, Web

Migration guide

:::note For SDK version before 3.0.0, this SDK uses the flutter_web_auth package. :::

  1. Upgrade to the latest version
dependencies:
  logto_dart_sdk: ^3.0.0
  1. Update the manifest files (Android platform only)

Replace the flutter_web_auth callback activity with the new flutter_web_auth_2 in the AndroidManifest.xml file.

  • FlutterWebAuth -> FlutterWebAuth2
  • flutter_web_auth -> flutter_web_auth_2
  1. redirectUri parameter is now required for the signOut method.
await logtoClient.signOut(redirectUri);