pexels 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 61

pexels #

Pexels REST client for Dart

Usage #

To use this library, add pexels as a dependency in your pubspec.yaml file.

Getting Started #

// import pexels
import "package:pexels/pexels.dart";

// create client instance
var client = PexelsClient('your_key_here');

// get a photo from ID
Photo photo = await client.getPhoto(id);

// get a random photo
Photo photo = await client.getPhoto();    // notice that the getPhoto method is called with no arguments.

// get the photo's url
String photoUrl = photo.sources['original'].link
// equivalent to:
String photoUrl = photo.get(ImageFormats.original);

// search photos
SearchResult<Photo> result = await client.searchPhotos(query,collection: Collection.Popular,page: 1,resultsPerPage:15);
Photo photo = result[0]; // get the first photo found.

// get a video from ID
Video video = await client.getVideo(id);

// get a random video
Video video = await client.getVideo();    // notice that the getVIdeo method is called with no arguments.

// get a video source url
String videoUrl = video.sources[0].link;
// equivalent to:
String videoUrl = video.get(0);

// search videos
SearchResult<Video> result = await client.searchVideos(query,collection: Collection.Regular,page: 1,resultsPerPage:15);
Video video = result[0]; // get the first video found.

// get Quota - bundles statistics about the API usage.
Quota quota = await client.getQuota();



0.1.1 #

  • Minor fixes.

0.1.0 #

  • Minor fixes.

0.0.1 #

  • Initial Release


import "dart:io";
import "../lib/pexels.dart";

void main() async {

  var client = new PexelsClient('key');

  var p = await client.getPhoto(); // get a random video.
  var link = p.get(ImageFormats.small);

  var vid = await client.getVideo(id:857251);

  var result = await client.searchPhotos("tree");
  var photo = result[0];

  var result2 = await client.searchVideos("balloon");
  var video = result2[0];

  var quota = await client.getQuota();

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  pexels: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:pexels/pexels.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/pexels_client.dart. (-2.48 points)

Analysis of lib/src/pexels_client.dart reported 5 hints:

line 21 col 25: Unnecessary new keyword.

line 32 col 16: Unnecessary new keyword.

line 117 col 12: Unnecessary new keyword.

line 186 col 27: Unnecessary new keyword.

line 234 col 12: Unnecessary new keyword.

Fix lib/src/pexels_quota.dart. (-0.50 points)

Analysis of lib/src/pexels_quota.dart reported 1 hint:

line 15 col 20: Unnecessary new keyword.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
test >=1.0.0