搜索插件、代码仓与 APP 分类

插件详情v0.6.0

dart_twitter_api

一个用于使用 Twitter API 的 Dart 包,每个端点都有详细的文档接口。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1080
喜欢数
44
Pub 分数
150

安装插件

flutter pub add dart_twitter_api

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Dart 包,为 Twitter API 提供了文档齐全的封装,可实现与跨平台 Flutter 应用的无缝集成。它为所有 Twitter API 端点提供了清晰的接口,简化了认证、数据获取和发布功能。专为希望在其应用中构建社交媒体功能(如获取推文、用户互动和实时更新)的开发者设计。该包支持 Android、iOS、Web、macOS、Windows 和 Linux,确保广泛的兼容性。其结构化方法减少了样板代码,提升了代码可维护性。

适合场景

  • 获取推文和时间线
  • 用户配置文件管理
  • 发布和回复推文
  • 实时馈送更新
  • 社交媒体分析
  • 集成 Twitter 登录

主要特点

  • 全面的端点覆盖
  • 文档齐全的 API
  • 跨平台支持
  • 身份验证助手
  • 类型安全的请求/响应模型
  • 活跃的 GitHub 维护

适合对象

  • Flutter 开发人员构建社交应用
  • 需要 Twitter 集成的应用程序
  • 需要多平台支持的项目
  • 注重代码结构清晰的开发者
  • 使用 OAuth 工作流的团队

使用建议

  • 需要 Twitter 开发者账户
  • 速率限制适用
  • 需要适当的错误处理
  • 依赖外部API的稳定性
  • 可能需要令牌刷新逻辑

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

A Dart wrapper for the Twitter API v1.1

pub test

This dart package provides a well documented wrapper for the Twitter v1.1 API.

To access the v2 endpoints, check out twitter-api-v2.

Why use this package?

To make the usage as convenient and comfortable as possible, this package provides interfaces for the various endpoints of the Twitter API. Documentation for each request is available as dart docs and each request's parameters can be changed as named parameters.

The various data structures returned by Twitter are parsed into data models in an isolate.

Example usage

example

Twitter API key

Get your Twitter API key here.

Features

Implemented endpoints

The implemented API endpoints are available as methods in the corresponding service. The request parameters can be set through named parameters and the response will be parsed into a data object for maximum convenience.

Find a list of implemented endpoints here.


If an API endpoint is not yet implemented, a request can be made to that endpoint by manually using the TwitterClient from the TwitterApi object.

See Making a custom request to the Twitter API for an example.

Error handling

Requests made by the client can throw the following errors:

  • TimeoutException when a request hasn't returned a response for some time (defaults to 10s, can be changed in the TwitterClient).

  • Response when the received response does not have a 2xx status code. Most responses include additional error information that can be parsed manually from the response's body. Check out the Twitter Developer documentation of the endpoint for possible error responses (Hyperlinked in the dart doc for each endpoint).

  • Other unexpected errors in unlikely events (for example when parsing the response).


For an example of uploading media files to Twitter, see Attaching media to a Tweet.

Development

Contribution

I appreciate any contributions to this package. Any not yet implemented endpoints can be added similarly to the other implementations. Feel free to reach out to me to ask any questions.

Please make sure dartanalyzer doesn't report any problems before opening a pull request.

Miscellaneous
  • To generate json_serializable models
    • dart run build_runner build --delete-conflicting-outputs

所属分类

依赖

依赖清单 4 项

源码仓库

使用此插件的项目