搜尋套件、儲存庫與 APP 分類

套件詳情v4.0.0

unsplash_client

Unsplash 提供免費的高解析度照片。這是他們 REST API 的客戶端。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3790
喜歡數
67
Pub 分數
160

安裝套件

flutter pub add unsplash_client

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

unsplash_client 套件是 Unsplash REST API 的 Dart 客戶端,讓開發者能在 Flutter 應用中直接取得高解析度、免費使用的照片。該套件透過提供對搜尋、取得和管理照片、使用者及收藏夾等端點的結構化存取,簡化了與 Unsplash 圖像資料庫的整合。此套件支援所有主要平台,包含行動裝置、網頁與桌面端,非常適合需要動態且視覺豐富內容的應用程式。以乾淨直覺的 API,減少處理 Unsplash 資料時的重複程式碼。

適用情境

  • 獲取隨機或搜尋的圖片
  • 顯示精選照片合集
  • 將免費股票照片整合到應用程式中
  • 建構視覺內容發現功能
  • 透過高品質影像增強應用UI

主要特色

  • 簡單的 REST API 包裝器
  • 支援所有平台(Android、iOS、Web、macOS、Windows、Linux)
  • 照片、使用者和收藏夾的內建模型
  • 輕鬆搜尋和分頁
  • 類型安全的回應
  • 活躍維護和開源

適合對象

  • 需要免費股票圖片的應用
  • 注重設計或視覺內容的平台
  • 照片畫廊或靈感應用
  • 使用 Flutter 的跨平台專案
  • 尋求可靠圖像來源的開發者

使用建議

  • 需要來自 Unsplash 的 API 金鑰
  • 每個 API 密鑰都有速率限制
  • 僅限 Unsplash 的圖像庫
  • 依賴網路連接
  • 可能需要快取以供離線使用

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

pub.dev package page GitHub Actions CI GitHub Stars

Unsplash provides free high-resolution photos. This is a client for their REST API.


If you're looking for a database solution, check out cbl, another project of mine. It brings Couchbase Lite to standalone Dart and Flutter, with support for:

  • Full-Text Search,
  • Expressive Queries,
  • Data Sync,
  • Change Notifications

and more.


Limitations

Endpoints that act on behalf of a user are not implemented, yet.If that is something you need, please comment on this issue.

Requirements

You need to register as a developer and create an Unsplash app to access the API.

Getting started

Create an UnsplashClient

Use the credentials for your app, obtained from the developer portal, to create an UnsplashClient:

final client = UnsplashClient(
  settings: ClientSettings(credentials: AppCredentials(
    accessKey: '...',
    secretKey: '...',
  )),
);

:warning: When you are done using a client instance, make sure to call it's close method.

Get a random photo

// Call `goAndGet` to execute the [Request] returned from `random`
// and throw an exception if the [Response] is not ok.
final photos = await client.photos.random(count: 1).goAndGet();

// The api returns a `Photo` which contains metadata about the photo and urls to download it.
final photo = photos.first;

Photo variants

A Photo comes with a set of urls for variants of the photo of different sizes, such as regular and thumb:

final thumb = photo.urls.thumb;

If the provided variants are not a good fit for your use, you can generate urls where you specify size, quality, fit and other parameters.

Call the extension method Uri.resizePhoto on photo.urls.raw to generate an Uri for a custom variant:

final custom = photo.urls.raw.resizePhoto(width: 400, height: 400);

Example

The example is a simple CLI app that fetches a few random photos.


Gabriel Terwesten • GitHub @blaugold • Twitter @GTerwesten • Medium @gabriel.terwesten

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案