搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案