? unofficial_twitch_auth
这个包允许通过最新的 Twitch API 获取所有数据。
可在 pub.dev 上找到:https://pub.dev/packages/unofficial_twitch_open_api
入门
要使 API 正常工作,您需要在 Twitch Dev Console 上配置您的应用程序。如果您不
知道如何操作,请按照
此处 此处 提供的步骤操作。
.
为了访问 Twitch 的数据,实现了
类 TwitchManagerOpenApi。这个工具创建了
可用的 BaseTwitchOpenApi 子类的实例。
/// You can create the instance of [TwitchManagerOpenApi] via provider or get_it
/// An example below:
List<SingleChildWidget> _initProvider() {
String clientId = 'your_secret_client_id';
return [
Provider<TwitchManagerOpenApi>(
create: (ctx) =>
TwitchManagerOpenApi(
clientId: clientId,
),
),
];
}
/// Then, you can use the instance created previously to retrieve the subclass needed
T getInstance<T extends BaseTwitchOpenApi>() {
final manager = Provider.of<TwitchManagerOpenApi>();
return manager.of<T>(bearerToken: 'your_secret_token');
}
/// Finally, use the instance. An example below:
final channelInfo = getInstance<TwitchChannelInformation>(
bearerToken: 'your_secret_token',
).getChannelInformation(broadcasterId: broadcasterId);