pixabay_picker 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 84

pixabay_picker #

A new Flutter/Dart package project.

Getting Started #

We have provided a pure dart API for getting media from pixabay.com.

Later on we will enhance this project with a Flutter Media picker too.

Usage: #

Create API interface #

Note that you can search pixabay localized, if you set the language parameter accordingly in constructor

  PixabayPicker picker = PixabayPicker(apiKey: ApiKey, language: "hu");

Get images for business category #

  PixabayResponse res = await picker.api
      .requestImages(resultsPerPage: 4, category: Category.business);   

You can iterate the result like this

  res.hits.forEach((f) {
      // use your media
      print(f);
    });

Get Images with keywords #

// get 30 image tagged as dog from pixabay
// note we created the api object with hungarian
// language so the keyword is in hungarian too

res =
      await api.requestImagesWithKeyword(keyword: "kutya", resultsPerPage: 30);

Search other media #

You can search for videos too

 res =
      await api.requestVideosWithKeyword(keyword: "kutya", resultsPerPage: 30);

Download media #

  BytesBuilder bytes =
        await api.downloadMedia(res.hits[0], Resolution.medium);

Get 3 video and 3 image for each category #

  Stream<Map<String, Map<MediaType, PixabayResponse>>> result =
      api.requestMapByCategory(
          photoResultsPerCategory: 3, videoResultsPerCategory: 3);

  result.listen((Map<String, Map<MediaType, PixabayResponse>> onData) {
    var values = onData.values.toList();
    var keys = onData.keys.toList();

    print(keys[0] + ":" + values[0][MediaType.video].hits[0].toString());
    print(keys[0] + ":" + values[0][MediaType.photo].hits[0].toString());
  });

[0.2.1] - 2019.08.28.

  • Fixed thumbnail url for videos

[0.2.0] - 2019.08.08.

  • Added test cases + stream handling for porgress
  • Renamed PixabayImageProvider in PixabayMediaProvider due to the fact that we provide videos too

[0.1.5] - 2019.08.07.

  • Added getThumbnailLink() function

[0.1.4] - 2019.07.08.

  • Updated package according to recent dart SDK changes

[0.1.2] - 2019.03.07.

  • Updated package information

[0.1.1] - 2019.03.07.

  • Added dartdoc documentation

[0.1.0] - 2019.03.07.

  • First stable release

[0.0.2] - 2019.03.07.

  • Updated README.md

[0.0.1] - 2019.02.24.

  • Initial release of the API.

example/main.dart

/*
 * Copyright (c) 2019. Black Salt Kft.  All rights reserved.
 * Author: Albert Papp
 *
 */
import 'dart:io';

import 'package:pixabay_picker/model/pixabay_media.dart';
import 'package:pixabay_picker/pixabay_api.dart';

import 'key.dart'; // import your API key

void main() async {
  PixabayMediaProvider api =
      PixabayMediaProvider(apiKey: ApiKey, language: "hu");

  PixabayResponse res =
      await api.requestImages(resultsPerPage: 1, category: Category.business);

  if (res != null) {
    res.hits.forEach((f) {
      print(f);
    });
  }

  print("--------------------------------------");

  res =
      await api.requestImagesWithKeyword(keyword: "kutya", resultsPerPage: 30);

  if (res != null) {
    res.hits.forEach((f) {
      print(f);
    });

    BytesBuilder bytes =
        await api.downloadMedia(res.hits[0], Resolution.medium);

    print(bytes.length);
  }

  res = await api.requestVideos();

  if (res != null) {
    res.hits.forEach((f) {
      print(f);
    });
  }

  res =
      await api.requestVideosWithKeyword(keyword: "kutya", resultsPerPage: 30);
  if (res != null) {
    res.hits.forEach((f) {
      print(f);
    });

    BytesBuilder bytes =
        await api.downloadMedia(res.hits[0], Resolution.medium);

    print(bytes.length);
  }

  Stream<Map<String, Map<MediaType, PixabayResponse>>> result =
      api.requestMapByCategory(
          photoResultsPerCategory: 3, videoResultsPerCategory: 3);

  result.listen((Map<String, Map<MediaType, PixabayResponse>> onData) {
    var values = onData.values.toList();
    var keys = onData.keys.toList();

    print(keys[0] + ": Thumbnail " + values[0][MediaType.video].hits[0].getThumbnailLink());
    print(keys[0] + ":" + values[0][MediaType.video].hits[0].toString());
    print(keys[0] + ": Thumbnail " + values[0][MediaType.photo].hits[0].getThumbnailLink());
    print(keys[0] + ":" + values[0][MediaType.photo].hits[0].toString());
  });
}

Use this package as a library

1. Depend on it

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


dependencies:
  pixabay_picker: ^0.2.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:pixabay_picker/pixabay_picker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
69
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]
84
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
test ^1.0.0