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

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());
  });
}
10
likes
120
pub points
71%
popularity

Publisher

verified publisherblacksalt.io

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, universal_io

More

Packages that depend on pixabay_picker