pixabay_picker 0.1.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 78

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.1.3] - 2019.03.27.

  • Added getThumbnail() function

[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 {
  PixabayImageProvider api =
      PixabayImageProvider(apiKey: ApiKey, language: "hu");

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

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

  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);
      print(f.getThumbnail());
    });

    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] + ":" + values[0][MediaType.video].hits[0].toString());
    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.1.3

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';
  
Version Uploaded Documentation Archive
0.1.3 Mar 28, 2019 Go to the documentation of pixabay_picker 0.1.3 Download pixabay_picker 0.1.3 archive
0.1.2 Mar 7, 2019 Go to the documentation of pixabay_picker 0.1.2 Download pixabay_picker 0.1.2 archive
0.1.1 Mar 7, 2019 Go to the documentation of pixabay_picker 0.1.1 Download pixabay_picker 0.1.1 archive
0.1.0 Mar 7, 2019 Go to the documentation of pixabay_picker 0.1.0 Download pixabay_picker 0.1.0 archive
0.0.2 Mar 7, 2019 Go to the documentation of pixabay_picker 0.0.2 Download pixabay_picker 0.0.2 archive
0.0.1 Mar 7, 2019 Go to the documentation of pixabay_picker 0.0.1 Download pixabay_picker 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
57
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

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

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/model/pixabay_media.dart.

Run flutter format to format lib/model/pixabay_media.dart.

Maintenance issues and suggestions

Support latest dependencies. (-5 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency.

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
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test