Search packages, repositories and app categories

Package detailsv4.0.0

unsplash_client

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

AndroidiOSWebmacOSWindowsLinux
30-day downloads
3.8K
Likes
67
Pub points
160

Install package

flutter pub add unsplash_client

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The unsplash_client package is a Dart client for the Unsplash REST API, enabling developers to fetch high-resolution, free-to-use photos directly in Flutter applications. It simplifies integration with Unsplash's image library by providing structured access to endpoints for searching, retrieving, and managing photos, users, and collections. The package supports all major platforms, including mobile, web, and desktop, making it ideal for apps requiring dynamic, visually rich content. With clean, intuitive APIs, it reduces boilerplate code when working with Unsplash’s data.

Use cases

  • Fetching random or searched images
  • Displaying curated photo collections
  • Integrating free stock photos into apps
  • Building visual content discovery features
  • Enhancing app UI with high-quality imagery

Key features

  • Simple REST API wrapper
  • Supports all platforms (Android, iOS, Web, macOS, Windows, Linux)
  • Built-in models for photos, users, and collections
  • Easy search and pagination
  • Type-safe responses
  • Active maintenance and open-source

Suitable for

  • Apps needing free stock images
  • Design-focused or visual content platforms
  • Photo gallery or inspiration apps
  • Cross-platform projects using Flutter
  • Developers seeking reliable image sourcing

Considerations

  • Requires API key from Unsplash
  • Rate limits apply per API key
  • Limited to Unsplash's image library
  • Depends on network connectivity
  • May need caching for offline use

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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

Categories

Dependencies

Dependency list 4 items

Source repository

Projects using this package