Getting Started with the Magic Client SDK for Flutter

Getting Started with the Magic Client SDK for Flutter

New to Magic?

Create a fully-functional Magic auth demo in minutes.

Build a demo

Overview

The Magic Flutter SDK is distributed on the pub.dev package manager. This is your entry-point to secure, passwordless authentication for your iOS or Android-based Flutter app. This guide will cover some important topics for getting started with client-side APIs and to make the most of Magic's features.

Magic can support either server-based or serverless applications. It is up to the developers to implement the Admin SDK to validate the DID Token.

Installation

Add magic_sdk to your pubspec.yaml:

dependencies: flutter: sdk: flutter magic_sdk: ^0.3.0

Run the following command to install dependencies

$ dart pub get

Create an SDK Instance

In main.dart, instantiate Magic with your publishable key

void main() { runApp(const MyApp()); Magic.instance = Magic("YOUR_PUBLISHABLE_KEY"); }

Use Stack in the top level and add Magic.instance.relayer to the children of Stack to ensure the best performance

class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( home: Stack(children: [ // Use Stack() here MaterialApp( title: 'Magic Demo', home: const LoginPage(), ), Magic.instance.relayer // Insert Magic relayer here ])); } }

Server-side SDKs ?

Integrate Magic with your existing backend.
Getting Started with the Magic Client SDK for Flutter