Magic for Flutter
Magic for Flutter
New to Magic?
Create a fully-functional Magic auth demo in minutes.
#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
:
01dependencies:
02 flutter:
03 sdk: flutter
04 magic_sdk: ^2.0.0
Run the following command to install dependencies
01$ dart pub get
#Create an SDK Instance
In main.dart
, instantiate Magic with your publishable key
01void main() {
02 runApp(const MyApp());
03
04 Magic.instance = Magic("YOUR_PUBLISHABLE_KEY");
05}
Use Stack
in the top level and add Magic.instance.relayer
to the children of Stack to ensure the best performance
01class MyApp extends StatelessWidget {
02 const MyApp({Key? key}) : super(key: key);
03
04 // This widget is the root of your application.
05
06 Widget build(BuildContext context) {
07 return MaterialApp(
08 home: Stack(children: [ // Use Stack() here
09 MaterialApp(
10 title: 'Magic Demo',
11 home: const LoginPage(),
12 ),
13 Magic.instance.relayer // Insert Magic relayer here
14 ]));
15 }
16}