Logto helps you quickly focus on everything after signing in.
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.
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.
Learn more about the flutter_web_auth_2 setup.
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
await logtoClient.signIn(redirectUri);
// Sign out
await logtoClient.signOut(redirectUri);
Check Flutter SDK guide for more details.
iOS, Android, Web
:::note For SDK version before 3.0.0, this SDK uses the flutter_web_auth package. :::
- Upgrade to the latest version
dependencies:
logto_dart_sdk: ^3.0.0
- 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
redirectUri
parameter is now required for thesignOut
method.
await logtoClient.signOut(redirectUri);