Flutter

This guide demonstrates how to add user authentication to a Flutter application using BlitzWare.

circle-info

This tutorial is based on the example apparrow-up-right.


1) Configure BlitzWare

Get Your Application Keys

You will need some details about your application to communicate with BlitzWare. You can get these details from the Application Settings section in the BlitzWare dashboard.

You need the Client ID.

Configure Redirect URIs

A redirect URI is a URL in your application where BlitzWare redirects the user after they have authenticated. The redirect URI for your app must be added to the Redirect URIs list in your Application Settings under the Security tab. If this is not set, users will be unable to log in to the application and will get an error.


2) Install the BlitzWare Flutter SDK

Run the following command within your project directory to install the BlitzWare Flutter SDKarrow-up-right:

Prerequisites

This SDK requires Flutter 3.0.0 or higher and includes the following key dependencies:

  • flutter_appauth - For OAuth 2.0 authentication with PKCE

  • flutter_secure_storage - For secure token storage

  • provider - For state management

  • http - For API communication

These dependencies are automatically installed with the SDK.

Platform Setup

iOS Setup

  1. Add URL scheme to your ios/Runner/Info.plist:

Replace yourapp with your actual app scheme.

Android Setup

  1. Add the redirect URI receiver activity to android/app/src/main/AndroidManifest.xml inside the <application> tag:

Replace yourapp with your actual app scheme.


3) Implementation Guide

Follow this step-by-step guide to implement authentication in your app.

1

Configure the Provider

Wrap your app with the BlitzWareAuthProvider at the root level in your main.dart:

2

Basic Authentication

Create your main authentication screen using the AuthStateBuilder widget:

3

Display User Information

Create a dashboard screen that displays user information and authentication status:

4

Access Token Management

Get access tokens for making authenticated API calls:

5

Role-Based Access Control

Implement role-based features using the RoleGuard widget:

You can also check roles programmatically using the provider:

6

Session Validation

Add session validation for enhanced security:


That's it! You now have a fully functional Flutter application with BlitzWare authentication.

For more information, check out the example apparrow-up-right which demonstrates all these features and more.

Last updated