login method

Future<LoginResult> login({
  1. List<String> scopes = const ['profile'],
  2. LoginOption? option,
})

Logs the user into LINE with the specified scopes and option, by either opening the LINE client for an existing logged in user, or a web view if the LINE client isn't installed on the user's device.

By default, the login process uses only "profile" as its required scope. If you need more scopes, put the ones you want (in addition to the default "profile") in scopes as a list.

If scopes contains "profile", the user profile is returned in the result as LoginResult.userProfile. If "profile" is not included, the value of LoginResult.userProfile will be null.

An access token is issued if the user authorizes your app. This token, along with a refresh token, is automatically stored in a secure place in your app for later use. You don't need to refresh the access token manually. Any following API calls will try to refresh the access token when necessary. However, you can refresh the access token manually with refreshToken().

You can control some other login behaviors, like whether to use a web page for login, or how to ask the user to add your LINE Official Account as a friend. To do so, create a LoginOption object and pass it to the option parameter.

This method redirects calls to the LINE SDK for the relevant native platform (iOS or Android). If an error happens in the native platform, a PlatformException is thrown. See PlatformException.code and PlatformException.message for error details.

The LINE SDK implementation differs between iOS and Android, which means error codes and messages can also be different. For platform-specific error information, see LineSDKError (iOS) and LineApiError (Android).

Implementation

Future<LoginResult> login(
    {List<String> scopes = const ['profile'], LoginOption? option}) async {
  return await channel.invokeMethod('login', <String, dynamic>{
    'loginRequestCode': option?.requestCode,
    'scopes': scopes,
    'onlyWebLogin': option?.onlyWebLogin,
    'botPrompt': option?.botPrompt,
    'idTokenNonce': option?.idTokenNonce,
  }).then((value) => LoginResult._(_decodeJson(value)));
}