> For the complete documentation index, see [llms.txt](https://docs.wepin.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wepin.io/en/deprecated/flutter-sdk/method.md).

# Methods

The following shows the methods provided by the Wepin widget flutter SDK.

## `openWidget`

The <mark style="color:blue;">`openWidget`</mark> method shows the widget window.

### Example

```dart
_wepin.openWidget();
```

## `closeWidget`

The <mark style="color:blue;">`closeWidget`</mark> method closes the widget window.

### Example

```dart
_wepin.closeWidget();
```

## `getAccounts`

The <mark style="color:blue;">`getAccounts`</mark> method returns user accounts of the networks available in the app. The returned value is an array of <mark style="color:blue;">`Account`</mark> object. <mark style="color:blue;">`getAccounts`</mark> is a method available after widget login.

```dart
List<Account> accounts = _wepin.getAccounts();
```

### `Account`

The interface of the class returned by the <mark style="color:blue;">`getAccounts`</mark> function is as follows, and it is defined in <mark style="color:blue;">`wepin_outputs.dart`</mark>.

```dart
class Account {
    final dynamic? _network;  // The blockchain network of the account
    final dynamic? _address; // The account address
}
```

* **`network`**: *dynamic*\
  The blockchain network of the account. The name of each network can be found below.

{% content-ref url="/pages/c58QTBKZd8FibB8m3Pc4" %}
[Supported blockchains](/en/wepin/supported-blockchains.md)
{% endcontent-ref %}

* **`address`:** *dynamic*\
  The account address

## `finalize`

The state of Wepin is initialized.

### Example

```dart
_wepin.finalize();
```

## `getStatus` (Supporting from version <mark style="color:blue;">`0.0.4-alpha`</mark> or higher)

It returns the Lifecycle state value of Wepin.

### Example

```dart
await _wepin.getStatus()
```

### The Returned Values

* `not_initialized`: Wepin is not initialized.
* `initializing`: Wepin initialization is in progress.
* `initialized`: Wepin initialization is completed.
* `before_login`: Wepin initialized, but the user is not logged in.
* `login`: The user is logged in.

## `login` (Supporting from version <mark style="color:blue;">`0.0.4-alpha`</mark> or higher)

If the user is not logged in, it shows the widget window. If the user is already logged in, it returns the logged-in user information.

### Example

```dart
await _wepin.login()
```

### `WepinUser`

The interface of the returned value class for the function is defined as follows, and it is defined in <mark style="color:blue;">`wepin_outputs.dart`</mark>.

```dart
class WepinUser {
    final String _status;
    final UserInfo? _userInfo;
}

class UserInfo {
  final dynamic _userId;
  final dynamic _email;
  final dynamic _provider;
}
```

* **`status`**:  *<'success' | 'fail'>*\
  login success status *<'success' | 'fail'>*
* **`UserInfo`**: Information about the user
  * `userId`: User ID
  * `email`: User email address
  * `provider`: Information about the logged-in provider *<'google'|'apple'|'email'|'naver'|'discord'|'external\_token'>*

## `getSignForLogin` (Supporting from version <mark style="color:blue;">`0.0.4-alpha`</mark> or higher)

[<mark style="color:blue;">`loginWithExternalToken()`</mark>](#loginwithexternaltoken-supporting-from-version-0.0.4-alpha-or-higher) returns a signed token value used for login.

### Example

```dart
_wepin.getSignForLogin(privateKey, token);
```

### Parameters

* **`privateKey`\<String>**: PrivateKey value used to sign the token for [<mark style="color:blue;">`loginWithExternalToken()`</mark>](#loginwithexternaltoken-supporting-from-version-0.0.4-alpha-or-higher).
* **`token`\<String>**: Token value received after logging in with OAuth.

{% hint style="info" %}
The key for signing can be obtained from [Wepin Workspace](https://workspace.wepin.io/). In the Development Tools menu, click **Get your authentication key** on the Login tab to retrieve the authentication key.
{% endhint %}

### Returned Values

* **`signedToken`\<String>**: The value of the token signed with the <mark style="color:blue;">`privateKey`</mark>.

## `loginWithExternalToken` (Supporting from <mark style="color:blue;">`version 0.0.4-alpha`</mark> or higher)

Log in to Wepin with the token value received after logging in with OAuth.

### Example

```dart
await _wepin.loginWithExternalToken(token, signedToken)
```

### Parameters

* **`token`\<String>**: External token value to be used for login (e.g., idToken).
* **`signedToken`\<String>**: The signature value received after executing  [<mark style="color:blue;">`getSignForLogin()`</mark>](#getsignforlogin-supporting-from-version-0.0.4-alpha-or-higher) as the first parameter.

### Returned Values

* **`WepinUser`**

  The interface of the returned value class for the function is defined as follows, and it is defined in <mark style="color:blue;">`wepin_outputs.dart`</mark>.

  ```dart
  class WepinUser {
      final String _status;
      final UserInfo? _userInfo;
  }

  class UserInfo {
    final dynamic _userId;
    final dynamic _email;
    final dynamic _provider;
  }
  ```

  * **`status`**:  *<'success' | 'fail'>*\
    login success status *<'success' | 'fail'>*
  * **`UserInfo`**: Information about the user
    * `userId`: User ID
    * `email`: User email address
    * `provider`: Information about the logged-in provider *<'google'|'apple'|'email'|'naver'|'discord'|'external\_token'>*

## `logout` (Supporting from version <mark style="color:blue;">`0.0.4-alpha`</mark> or higher)

It logs out the user logged into Wepin.

### Example

```dart
await _wepin.logout()
```

### Returned Values

* **`WepinUser`**

  The interface of the returned value class for the function is defined as follows, and it is defined in <mark style="color:blue;">`wepin_outputs.dart`</mark>.

  ```dart
  class WepinUser {
      final String _status;
      final UserInfo? _userInfo;
  }

  class UserInfo {
    final dynamic _userId;
    final dynamic _email;
    final dynamic _provider;
  }
  ```

  * **`status`**:  *<'success' | 'fail'>*\
    login success status *<'success' | 'fail'>*
  * **`UserInfo`**: Information about the user
    * `userId`: User ID
    * `email`: User email address
    * `provider`: Information about the logged-in provider *<'google'|'apple'|'email'|'naver'|'discord'|'external\_token'>*
