Methods
Here are the methods provided by the Wepin Flutter Widget SDK.
getStatus
Returns the lifecycle status of the WepinSDK.
Parameters
None
Return value
Future<WepinLifeCycle>
notInitialized: WepinSDK has not been initialized.
initializing: WepinSDK is in the process of initializing.
initialized: WepinSDK has been successfully initialized.
beforeLogin: WepinSDK is initialized, but the user is not logged in.
login: The user is logged in and registered with Wepin.
loginBeforeRegister: The user is logged in but not registered with Wepin.
Example
login
The login
variable is a Wepin login library that includes various authentication methods, allowing users to log in using different approaches. It supports email and password login, OAuth provider login, login using ID tokens or access tokens, and more. For detailed information on each method, refer to the official Login Library guide.
Available Methods
These methods support various login scenarios, allowing you to select the appropriate method based on your needs.
Exception
Example
loginWithUI
The loginWithUI()
method provides the functionality to log in using a widget and returns the information of the logged-in user. If a user is already logged in, the widget will not be displayed, and the method will directly return the logged-in user's information. To perform a login without the widget, use the loginWepin()
method from the login
variable instead.
This method can only be used after the authentication key has been deleted from the Wepin Workspace. (Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)
The Auth Key menu is visible only if an authentication key was previously generated.
Supported Version
Supported from version 0.0.4
and later.
Parameters
context
<BuildContext>
In Flutter,context
represents the location within the widget tree, allowing you to locate widgets, access theme data, and handle navigation. When callingloginWithUI
, you should pass the current context to ensure that the widget is displayed in the correct part of the UI hierarchy.loginProviders<
List<LoginProvider>
> - An array of login providers to configure the widget. If an empty array is provided, only the email login function is available.provider <
String
> The OAuth login provider (e.g., 'google', 'naver', 'discord', 'apple').clientId <
String
> The client ID of the OAuth login provider.
email<
String
> optional Theemail
parameter allows users to log in using the specified email address when logging in through the widget.
To use OAuth login functionality (e.g., loginWithUI
), you need to configure OAuth login providers. You must first register your OAuth login provider information in the Wepin Workspace. For more details on setting up OAuth providers, refer to the Social Login OAuth Providers documentation.
Return Value
Future<WepinUser>
status
<String>
Indicates success or failure ('success'|'fail').userInfo
<WepinUserInfo>
optional - User information.userId
<String>
Wepin user ID.
email
<String>
The email address of the user logged in to Wepin.
provider
<String>
Login provider ('google'|'apple'|'naver'|'discord'|'email'|'external_token').
use2FA
<bool>
Indicates whether 2FA is enabled on the user’s wallet.
userStatus
<WepinUserStatus>
: User status.loginStatus
<String>
Login status ('complete' | 'pinRequired' | 'registerRequired'). If the user's
loginStatus
is not 'complete', they need to register with Wepin.pinRequired
<bool>
optional Indicates if a PIN is required.
walletId
<String>
Wepin user’s wallet ID.token
<WepinToken>
Wepin token information.
Exception
Example
openWidget
Opens the widget window. If the user is not logged in, the widget window will not open. Therefore, the user must be logged in to Wepin before calling openWidget
. To log in to Wepin, use the loginWithUI
or loginWepin
method from the login
variable.
Parameters
context
<BuildContext>
Represents the location of a widget in the widget tree in Flutter. This context is used to locate the widget’s position and to provide various functions like navigation, accessing theme data, and more. When callingopenWidget
, pass the current context to ensure the widget is displayed within the correct part of the UI hierarchy.
Return Value
Future<void>
Exception
Example
closeWidget
Closes the widget window. Closing the window does not log out the user.
Parameters
None
Return Value
void
Exception
Example
register
Registers the user with Wepin. After signing up and logging in, the Wepin widget’s registration page opens, allowing the user to register (create a wallet and account) with Wepin services. This function can only be used when WepinLifeCycle
is loginBeforeRegister
. After calling the loginWepin()
method from the login
variable, if the loginStatus
value in userStatus
is not 'complete', this method should be called.
Parameters
context
<BuildContext>
Represents the location of a widget in the widget tree. It is used to locate the widget's position in the tree and to provide various functions like navigation and accessing theme data. Pass the current context when callingregister
to ensure the widget is displayed in the correct part of the UI hierarchy.
Return Value
Future<WepinUser>
status
<String>
Indicates success or failure ('success'|'fail').userInfo
<WepinUserInfo>
optional - User information.userId
<String>
Wepin user ID.
email
<String>
The email address of the user logged in to Wepin.
provider
<String>
Login provider ('google'|'apple'|'naver'|'discord'|'email'|'external_token').
use2FA
<bool>
Indicates whether 2FA is enabled on the user’s wallet.
userStatus
<WepinUserStatus>
: User status.loginStatus
<String>
Login status ('complete' | 'pinRequired' | 'registerRequired'). If the user's
loginStatus
is not 'complete', they need to register with Wepin.pinRequired
<bool>
optional Indicates if a PIN is required.
walletId
<String>
Wepin user’s wallet ID.token
<WepinToken>
Wepin token information.
Exception
Example
getAccounts
Returns the user's account information (networks and addresses) available in the app. This function can only be used after logging in to Wepin. If no parameters are provided, it returns information for all the user's accounts.
Parameters
networks
<List<String>>
optional The networks for which you want to return account information. The supported blockchain networks can be found on the supported blockchain page.withEoa
<bool>
optional If AA accounts are present, this determines whether to include EOA accounts in the return.
Return Value
Future <List<WepinAccount>>
address
<String>
User account address.network
<String>
The network type of the user's account.
contract
<String>
optional The contract address of the token.isAA
<bool>
optional Indicates if it is an AA account.
Exception
Example
response
getBalance
Returns the balance information (amount) of accounts. This function can only be used after logging in to Wepin. If no accounts
parameter is provided, it returns the balance of all user accounts.
Parameters
accounts
<List<WepinAccount>>
optionalnetwork
<String>
The network type of the account for which to check the balance.
address
<String>
The address of the account for which to check the balance.
isAA
<bool>
optional Indicates if it is an AA account.
Return Value
Future <List<WepinAccountBalanceInfo>>
network
<String>
The network type of the user's account.
address
<String>
The address of the user's account.
symbol
<String>
Network symbol.
balance
<String>
The amount of the network coin held.
tokens
<List<WepinTokenBalanceInfo>>
symbol
<String>
Token symbol.
balance
<String>
The amount of the token held.
contract
<String>
Token contract address.
Exception
Example
response
getNFTs
Returns the user's NFTs. This function can only be used after logging in to Wepin. If no networks
parameter is provided, it returns all of the user's NFT information.
Parameters
refresh
<bool>
Required parameter to indicate whether to refresh the NFT data.networks
<List<String>>
optional A list of network names to filter the NFTs.
Return Value
Future<List<WepinNFT>>
account
<WepinAccount>
address
<String>
User account address.network
<String>
The network type of the user's account.contract
<String>
optional Token contract address.isAA
<bool>
optional Indicates if it is an AA account.
contract
<WepinNFTContract>
name
<String>
NFT contract name.address
<String>
NFT contract address.scheme
<String>
Scheme of the NFT.description
<String>
optional Description of the NFT contract.network
<String>
Network associated with the NFT contract.externalLink
<String>
optional External link associated with the NFT contract.imageUrl
<String>
optional Image URL associated with the NFT contract.
name
<String>
Name of the NFT.description
<String>
Description of the NFT.externalLink
<String>
External link associated with the NFT.imageUrl
<String>
Image URL associated with the NFT.contentUrl
<String>
optional URL pointing to the content associated with the NFT.quantity
<int>
Quantity of the NFT.contentType
<String>
Content type of the NFT ('image' | 'video').state
<int>
State of the NFT.
Exception
Example
Response
send
Performs the send function using the widget and returns the ID information of the send transaction. This function can only be used after logging in to Wepin.
Parameters
context
<BuildContext>
Represents the location of a widget in the widget tree in Flutter. This context is used to locate the widget’s position and to provide various functions like navigation, accessing theme data, and more. When callingsend
, pass the current context to ensure the widget is displayed within the correct part of the UI hierarchy.account
<WepinAccount>
- The user's account information to send from.network
<String>
The type of network to send to.address
<String>
The address of the account to send to.contract
<String>
optional The contract address of the token.
txData
<WepinTxData>
optionalto
<String>
The address to send to.amount
<String>
The amount to send.
Return Value
Future <WepinSendResponse>
txId
<string>
The transaction ID of the send transaction.
Exception
Example
response
receive
The receive()
method opens the account information page associated with the specified account. This method can only be used after logging into Wepin.
Supported Version
Supported from version 0.0.4
and later.
Parameters
context
<BuildContext>
In Flutter,context
represents the location within the widget tree, allowing you to locate widgets, access theme data, and handle navigation. When callingreceive
, you should pass the current context to ensure that the widget is displayed in the correct part of the UI hierarchy.account
<WepinAccount>
- Provides the account information for the page that will be opened.network
<String>
The network associated with the account.address
<String>
The address of the account.contract
<String>
optional The contract address of the token.
Return Value
Future<WepinReceiveResponse>
account
<WepinAccount>
- The account information of the page that was opened.network
<String>
The network associated with the account.address
<String>
The address of the account.contract
<String>
optional The contract address of the token.
Exception
Example
finalize
Terminates the use of WepinSDK. The WepinLifeCycle
changes to notInitialized
.
Return Value
None
Example
WepinError
Last updated