pexels 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

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();

LICENSE #

see LICENSE

0.1.1 #

  • Minor fixes.

0.1.0 #

  • Minor fixes.

0.0.1 #

  • Initial Release

example/example.dart

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);
  stdout.write(link);

  var vid = await client.getVideo(id:857251);
  stdout.write(vid.sources[0].link);

  var result = await client.searchPhotos("tree");
  var photo = result[0];
  stdout.write(photo.sources['original'].link);

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

  var quota = await client.getQuota();
  stdout.write(quota);
  
}

Use this package as a library

1. Depend on it

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


dependencies:
  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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Oct 23, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:pexels/pexels.dart with components: io.

Dependencies

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