Skip to main content

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

ParameterDescription
networkThe 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
clientIdThe client id for your Web3Auth project. You can get it from Web3Auth dashboard.
sessionTimeSpecifies 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.

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",
),
);