패키지, 저장소 및 앱 카테고리 검색

패키지 상세v3.0.0

flutter_line_sdk

Flutter 앱에서 Dart와 함께 LINE SDK를 사용하기 위한 플러터 플러그인입니다.

AndroidiOS
30일 다운로드
2.9만
좋아요
79
Pub 점수
160

패키지 설치

flutter pub add flutter_line_sdk

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Flutter 애플리케이션에 LINE SDK를 통합할 수 있도록 해주는 플러터 플러그인으로, 개발자가 LINE의 인증, 메시징 및 공유 기능을 활용할 수 있게 합니다. 안드로이드와 iOS 플랫폼 모두를 지원하며, 앱 내에서 LINE 로그인, 리치 메시지, 상호작용 콘텐츠를 원활하게 추가할 수 있습니다. 이 플러그인은 LINE 개발자들이 유지보수하고 있으며, pub.dev를 통해 간편하게 설정할 수 있도록 설계되었습니다. Flutter의 크로스플랫폼 기능과 호환성을 유지하면서 LINE 생태계를 통해 사용자 참여를 촉진합니다.

사용 사례

  • LINE 로그인 인증 구현
  • LINE를 통한 앱 내 메시징 활성화
  • LINE을 통해 콘텐츠 공유하기
  • LINE Pay 기능 통합
  • 채팅 기반 사용자 경험 구축

주요 기능

  • Android 및 iOS용 크로스 플랫폼 지원
  • pub.dev를 통한 플러터와의 간편한 통합
  • 공식적으로 LINE에서 유지 관리됨
  • LINE 로그인 및 메시지 공유를 지원합니다
  • 다양한 플랫폼 간에 일관된 API를 제공합니다

적합한 대상

  • LINE 인증이 필요한 앱
  • 소셜 또는 커뮤니티 기반 애플리케이션
  • LINE Pay를 사용하는 전자상거래 앱
  • LINE 생태계를 기반으로 개발하는 개발자
  • 일본 또는 아시아 시장을 대상으로 하는 Flutter 프로젝트

고려 사항

  • LINE 개발자 콘솔에서 구성이 필요합니다
  • LINE 전용 기능에 한정
  • 완전한 기능을 사용하려면 추가 권한이 필요할 수 있습니다
  • 일부 기능은 디바이스에 LINE 앱이 설치되어 있어야 합니다
  • 비-LINE 관련 사용 사례에는 적합하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

flutter_line_sdk

build

A Flutter plugin that lets developers access LINE's native SDKs in Flutter apps with Dart.

The plugin helps you integrate LINE Login features in your app. You can redirect users to LINE or a web page where they log in with their LINE credentials. Example:

import 'package:flutter_line_sdk/flutter_line_sdk.dart';

void login() async {
    try {
        final result = await LineSDK.instance.login();
        setState(() {
            _userProfile = result.userProfile;
            // user id -> result.userProfile?.userId
            // user name -> result.userProfile?.displayName
            // user avatar -> result.userProfile?.pictureUrl
            // etc...
        });
    } on PlatformException catch (e) {
        // Error handling.
        print(e);
    }
}

For more examples, see the example app and API definitions.

Prerequisites

From version 2.0, flutter_line_sdk supports null safety. If you are still seeking a legacy version without null safety, check version 1.3.0.

  • Flutter 3.44.0 or later. Version 3.0 relies on Flutter's built-in Kotlin support for Android builds; if your project is still on an older Flutter version, use flutter_line_sdk 2.x instead.
  • iOS 15.0 or later as the deployment target
  • Android minSdkVersion set to 24 or higher (Android 7.0 or later)
  • LINE Login channel linked to your app

To access your LINE Login channel from a mobile platform, you need some extra configuration. In the LINE Developers console, go to your LINE Login channel settings, and enter the below information on the App settings tab.

iOS app settings
Setting Description
iOS bundle ID Required. Bundle identifier of your app. In Xcode, find it in your Runner project settings, on the General tab. Must be lowercase, like com.example.app. You can specify multiple bundle identifiers by typing each one on a new line.
iOS universal link Optional. Set to the universal link configured for your app. For more information on how to handle the login process using a universal link, see Universal Links support.
Android app settings
Setting Description
Android package name Required. Application's package name used to launch the Google Play store.
Android package signature Optional. You can set multiple signatures by typing each one on a new line.
Android scheme Optional. Custom URL scheme used to launch your app.

Installation

Adding flutter_line_sdk package

Use the standard way of adding this package to your Flutter app, as described in the Flutter documentation:

flutter pub add flutter_line_sdk

Now, the Dart part of flutter_line_sdk should be installed. Next, you need to set up LINE SDK for iOS and Android projects, respectively.

Set up LINE SDK
iOS

Open the file ios/Runner/Info.plist in a text editor and insert this snippet just before the last </dict> tag:

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <!-- Specify URL scheme to use when returning from LINE to your app. -->
      <string>line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    </array>
  </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
  <!-- Specify URL scheme to use when launching LINE from your app. -->
  <string>lineauth2</string>
</array>

Because LINE SDK now requires iOS 15.0 or above to provide underlying native features, while the default deployment target of Flutter is 13.0, you must set the deployment target to 15.0 or higher.

Swift Package Manager integration (default)

Following Flutter's official direction, Swift Package Manager is the default way of managing iOS native dependencies since Flutter 3.44, and it is the integration path this plugin primarily targets. The bundled example app uses Swift Package Manager exclusively and cannot be built with Swift Package Manager opted out.

Open the project and increase the Minimum Deployments of your app's target to 15.0.

CocoaPods integration (maintenance mode)

CocoaPods integration keeps working and remains supported, but it is in maintenance mode, in line with Flutter's own plan for CocoaPods. If your project has opted out of Swift Package Manager, add this line in the Runner target in ios/Podfile:

target 'Runner' do
+ platform :ios, '15.0'

  use_frameworks!
  use_modular_headers!
  ...
Android

To ensure compatibility with the latest features, you need to update the minSdk version in your app's build.gradle file to 24 or higher.

Here's how you can do it:

  1. Open your app's build.gradle file.
  2. Locate the android block, and within it, find the defaultConfig block.
  3. In the defaultConfig block, replace the current minSdk value with 24.

Here's a diff to show what your changes might look like:

android {
    defaultConfig {
-        minSdk flutter.minSdkVersion
+        minSdk 24
    }
}
Importing and using
Setup

Import flutter_line_sdk to any place you want to use it in your project:

import 'package:flutter_line_sdk/flutter_line_sdk.dart';

To use the package, you need to set up your channel ID. You can do this by calling the setup method, for example in the main function:

- void main() => runApp(MyApp());
+ void main() {
+   WidgetsFlutterBinding.ensureInitialized();
+   LineSDK.instance.setup("${your_channel_id}").then((_) {
+     print("LineSDK Prepared");
+   });
+   runApp(App());
+ }

This is merely an example. You can call setup any time you want, provided you call it exactly once, before calling any other LINE SDK methods.

To help you get started with this package, we list several basic usage examples below. All available flutter_line_sdk methods are documented on the Dart Packages site.

Login

Now you are ready to let your user log in with LINE.

Get the login result by assigning the value of Future<LoginResult> to a variable. To handle errors gracefully, wrap the invocation in a try...on statement:

void _signIn() async {
  try {
    final result = await LineSDK.instance.login();
    // user id -> result.userProfile?.userId
    // user name -> result.userProfile?.displayName
    // user avatar -> result.userProfile?.pictureUrl
  } on PlatformException catch (e) {
    _showDialog(context, e.toString());
  }
}

By default, login uses ["profile"] as its scope. In this case, when login is done, you have a userProfile value in login result. If you need other scopes, pass them in a list to login. See the Scopes documentation for more.

final result = await LineSDK.instance.login(
    scopes: ["profile", "openid", "email"]
);
// user email, if user set it in LINE and granted your request.
final userEmail = result.accessToken.email;

Although it might be useless, if you do not contain a "profile" scope, userProfile will be a null value.

Logout
try {
  await LineSDK.instance.logout();
} on PlatformException catch (e) {
  print(e.message);
}
Get user profile
try {
  final result = await LineSDK.instance.getProfile();
  // user id -> result.userId
  // user name -> result.displayName
  // user avatar -> result.pictureUrl
} on PlatformException catch (e) {
  print(e.message);
}
Get current stored access token
try {
  final result = await LineSDK.instance.currentAccessToken;
  // access token -> result?.value
} on PlatformException catch (e) {
  print(e.message);
}

If the user isn't logged in, it returns a null. A valid result of this method doesn't necessarily mean the access token itself is valid. It may have expired or been revoked by the user from another device or LINE client.

Verify access token with LINE server
try {
  final result = await LineSDK.instance.verifyAccessToken();
  // result.data is accessible if the token is valid.
} on PlatformException catch (e) {
  print(e.message);
  // token is not valid, or any other error.
}
Refresh current access token
try {
  final result = await LineSDK.instance.refreshToken();
  // access token -> result.value
  // expires duration -> result.expiresIn
} on PlatformException catch (e) {
  print(e.message);
}

Normally, you don't need to refresh access tokens manually, because any API call in LINE SDK will try to refresh the access token automatically when necessary. We do not recommend refreshing access tokens yourself. It's generally easier, more secure, and more future-proof to let the LINE SDK manage access tokens automatically.

Error handling

All APIs can throw a PlatformException with error code and a message. Use this information to identify when an error happens inside the native SDK.

Error codes and messages will vary between iOS and Android. Be sure to read the error definition on iOS and Android to provide better error recovery and user experience on different platforms.

Contributing

If you believe you found a vulnerability or you have an issue related to security, please DO NOT open a public issue. Instead, send us an email at [dl_oss_dev@linecorp.com](mailto:dl_oss_dev@linecorp.com).

Before contributing to this project, please read CONTRIBUTING.md.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.