Magic empowers developers to protect their users via an innovative, passwordless authentication flow without the UX compromises that burden traditional OAuth implementations.
Features
This is your entry-point to secure, passwordless authentication for your iOS or Android-based Flutter app.
Installation
Add magic_sdk
to your pubspec.yaml
:
dependencies:
flutter:
sdk: flutter
magic_sdk: ^3.0.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
Note: Relayer is required to establish communication between apps and Magic service. Make sure to have it in a stack whenever you need to authenticate or interact with blockchain
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Magic Demo',
home: Stack(children: [
const LoginPage(),
Magic.instance.relayer
]));
}
}
}
Authenticate your first user!
var token = await magic.auth.loginWithMagicLink(email: textController.text);
Additional information
For more detail, please check the Magic Link Flutter doc
Libraries
- magic_sdk
- modules/auth/auth_module
- modules/base_configuration
- modules/base_module
- modules/blockchain/blockchain
- modules/blockchain/supported_blockchain
- modules/user/user_module
- modules/user/user_response_type
- modules/web3/eth_network
- modules/web3/magic_credential
- provider/rpc_provider
- provider/types/relayer_request
- provider/types/relayer_response
- provider/types/rpc_request
- provider/types/rpc_response
- relayer/locale
- relayer/url_builder
- relayer/webview
- relayer/webview_loader_controller
- utils/string
- utils/typed_array_for_json