FLUTTER ECOSYSTEM

blaugold/unsplash_client

공식이 아닌, 플랫폼에 관계없는 Unsplash API 클라이언트입니다. Unsplash는 저작권 없이 사용할 수 있는 이미지를 제공합니다.

unsplash_client 프로젝트 이미지
Stars
27
Forks
21
최근 푸시(UTC)
2025. 3. 22.
프로젝트 상태
활성
Gabriel Terwesten GitHub avatar
GITHUB User

Gabriel Terwesten ↗

@lotumMunich
언어Dart

기술 주제

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 8 개

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

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