pixabay_picker 1.0.7 copy "pixabay_picker: ^1.0.7" to clipboard
pixabay_picker: ^1.0.7 copied to clipboard

A Dart package for pixabay.com. With the api you can search or download videos and images from pixabay.com

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. Safe search is default true. You can change this value in the constructor.

  PixabayPicker picker = PixabayPicker(apiKey: ApiKey, language: "hu", safeSearch: true);
copied to clipboard

Get images for business category #

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

You can iterate the result like this

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

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

copied to clipboard

Search other media #

You can search for videos too

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

copied to clipboard

Download media #

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

copied to clipboard

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

copied to clipboard
11
likes
130
points
138
downloads

Publisher

verified publisherblacksalt.io

Weekly Downloads

2024.09.19 - 2025.04.03

A Dart package for pixabay.com. With the api you can search or download videos and images from pixabay.com

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, universal_io

More

Packages that depend on pixabay_picker