magic_flutter_v2
A maintained fork of magic_sdk (from
magiclabs/magic-flutter) based on 6.0.1.
Magic empowers developers to protect their users via an innovative, passwordless authentication flow without the UX compromises that burden traditional OAuth implementations.
Why this fork
Upstream magic_sdk renders the relayer WebView with Visibility(visible: false) while the
overlay is idle, which takes the WKWebView offstage. On iOS the system then suspends its web
content process, so box.magic.link never emits MAGIC_OVERLAY_READY and queued relayer RPCs
(the loginWithOAuth result parsing, the first loginWithEmailOTP) hang forever.
This fork keeps the relayer WebView attached and painted at all times so it stays alive, but shrinks
it to a 1x1, pointer-ignoring box while the overlay is hidden — so it neither covers the host app
nor blocks touches to content below it. It expands to full size only while the overlay is visible.
The public API is unchanged from upstream 6.0.1; only the package name differs.
⚠️ Removal of loginWithMagicLink() ⚠️
As of v4.0.0, passcodes (ie. loginWithSMS(), loginWithEmailOTP()) are replacing Magic Links (ie. loginWithMagicLink()) for all of our Mobile SDKs. Learn more
Features
This is your entry-point to secure, passwordless authentication for your iOS or Android-based Flutter app.
Installation
Add magic_flutter_v2 to your pubspec.yaml:
dependencies:
flutter:
sdk: flutter
magic_flutter_v2: ^6.0.1
Run the following command to install dependencies
$ flutter pub get
Create an SDK Instance
In main.dart, instantiate Magic with your publishable key
import 'package:magic_flutter_v2/magic_flutter_v2.dart';
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) {
return MaterialApp(
title: 'Magic Demo',
home: Stack(children: [
const LoginPage(),
Magic.instance.relayer
]));
}
}
Authenticate your first user!
var token = await magic.auth.loginWithEmailOTP(email: textController.text);
Additional information
For more detail, please check the Magic Link Flutter doc.
License & credits
This package is a fork of magiclabs/magic-flutter, distributed under the Apache License 2.0. The original copyright remains with Magic Labs, Inc. See LICENSE. This fork adds the iOS relayer WebView fix described above.
Libraries
- magic_flutter_v2
- 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/types/DPop
- relayer/url_builder
- relayer/webview
- relayer/webview_loader_controller
- utils/string
- utils/typed_array_for_json