douyin 1.0.0 copy "douyin: ^1.0.0" to clipboard
douyin: ^1.0.0 copied to clipboard

Flutter plugin for douyin login,support platform for Android and iOS

抖音授权登录Flutter插件 #

功能 #

支持的API

注册抖音SDK

Future<String> registerDouyinApp({required String apiKey});

授权登录

⚠️scopeKey多个类型需要用英文逗号隔开,如trial.whitelist,user_info

Future<String> authorLogin({required String scopeKey});

监听授权登录回调

Stream<DouYinResp> respStream();

使用

Android: 在项目的android目录中的build.gradle里添加抖音SDK的仓库地址

repositories {
    google()
    mavenCentral()
    maven { url 'https://artifact.bytedance.com/repository/AwemeOpenSDK' }
}

iOS: 在项目的ios目录中的Podfile文件中导入抖音SDK

⚠️:需要注释掉use_frameworks!,因为抖音SDK有静态引用

pod 'DouyinOpenSDK'

Example

import 'dart:async';

import 'package:douyin/douyin.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _initState = "none";
  String _code = "";
  final _douyinPlugin = Douyin();

  @override
  void initState() {
    super.initState();
    initPlatformState();
    authorResultState();
  }

  void authorResultState() {
    _douyinPlugin.respStream().listen((event) {
      setState(() {
        _code = event.authCode;
      });
    });
  }

  Future<void> initPlatformState() async {
    String initState;
    initState = await _douyinPlugin.registerDouyinApp(apiKey: '');
    if (!mounted) return;

    setState(() {
      _initState = initState;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: [
            Center(
              child: Text('Running on: $_initState\n----$_code'),
            ),
            Center(
              child: ElevatedButton(
                  onPressed: () {
                    _douyinPlugin.authorLogin(
                      scopeKey: "trial.whitelist,user_info",
                    );
                  },
                  child: const Text('授权登录')),
            )
          ],
        ),
      ),
    );
  }
}

3
likes
0
points
30
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for douyin login,support platform for Android and iOS

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on douyin