Initializing Single Factor Auth Flutter SDK
After installation, the next step to use Web3Auth SFA Flutter is to initialize the SDK and is
achieved by init
method. This step requires passing various parameters that align with your
project preferences. It's important to note that the initialization process is critical to the
successful use of Web3Auth SFA Flutter.
Parameters
Construct and configure the init
method with the SFAParams
- Table
- Class
Parameter | Description |
---|---|
network | The Web3auth network to be used by the SDK. Supported values are Web3AuthNetwork.sapphire_mainnet , Web3AuthNetwork.sapphire_devnet ,Web3AuthNetwork.mainnet , Web3AuthNetwork.testnet , Web3AuthNetwork.cyan , and Web3AuthNetwork.aqua |
clientId | The client id for your Web3Auth project. You can get it from Web3Auth dashboard. |
sessionTime | Specifies the session duration in seconds. By default, the value is set to 86400 seconds (1 day), with a maximum session duration of up to 7 days. |
class SFAParams {
final Web3AuthNetwork network;
final String clientId;
final int sessionTime;
SFAParams(
{required this.network,
required this.clientId,
this.sessionTime = 86400});
Map<String, dynamic> toJson() {
return {
'network': network.name,
'clientId': clientId,
'sessionTime': sessionTime,
};
}
}
enum Web3AuthNetwork {
mainnet,
testnet,
cyan,
aqua,
celeste,
sapphire_testnet,
sapphire_mainnet
}
Initialize Web3AuthFlutter
Initialize the Web3AuthFlutter
plugin at the very beginning such as in the overriden initState
function.
import 'package:single_factor_auth_flutter/single_factor_auth_flutter.dart';
final _singleFactorAuthFlutterPlugin = SingleFactAuthFlutter();
await _singleFactorAuthFlutterPlugin.init(
SFAParams(
network: Web3AuthNetwork.mainnet,
clientId: "YOUR_WEB3AUTH_CLIENT_ID",
),
);