Coder Social home page Coder Social logo

giphy_get's Introduction

giphy_get

Flutter_Tests pub package pub package style: lint

Overview

This package allow to get gifs, sticker or emojis from GIPHY in pure dart code using Giphy SDK design guidelines.

Inspiration

Result

Getting Started

Important! you must register your app at Giphy Develepers and get your APIKEY

Localizations

Currently english and spanish is supported.

return MaterialApp(
      title: 'Giphy Get Demo',
      localizationsDelegates: [
        // Default Delegates
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,

        // Add this line
        GiphyGetUILocalizations.delegate
      ],
      supportedLocales: [
        // Your supported languages
        Locale('en', ''),
        Locale('es', ''),
        Locale('da', ''),
      ],
      home: MyHomePage(title: 'Giphy Get Demo'),
      themeMode: Provider.of<ThemeProvider>(context).currentTheme,
    );

Get only Gif

This is for get gif without wrapper and tap to more

import 'package:giphy_get/giphy_get.dart';

GiphyGif gif = await GiphyGet.getGif(
  context: context, //Required
  apiKey: "your api key HERE", //Required.
  lang: GiphyLanguage.english, //Optional - Language for query.
  randomID: "abcd", // Optional - An ID/proxy for a specific user.
  tabColor:Colors.teal, // Optional- default accent color.
  debounceTimeInMilliseconds: 350, // Optional- time to pause between search keystrokes
);

Options

Value Type Description Default
lang String Use ISO 639-1 language code or use GiphyLanguage constants GiphyLanguage.english
randomID String An ID/proxy for a specific user. null
searchText String Input search hint, we recomend use flutter_18n package for translation "Search GIPHY"
tabColor Color Color for tabs and loading progress, Theme.of(context).accentColor
debounceTimeInMilliseconds int Time to pause between search keystrokes 350
showGIFs bool Whether to show the GIFs tab or not true
showStickers bool Whether to show the stickers tab or not true
showEmojis bool Whether to show the emojis tab or not true
tapTopBuilder Widget Function(BuildContext context) A custom builder for tab top. Must return a widget that will replace default Giphy-like tab top null. Displays default Giphy-like tab top
tabBottomBuilder Widget Function(BuildContext context) A custom builder for tab bottom. Must return a widget that will replace default Giphy credits logo. Note that credits are required to be shown by Giphy null. Displays default Giphy credits logo
searchAppBarBuilder Widget Function(BuildContext context,FocusNode focusNode,bool autofocus,TextEditingController textEditingController,void Function() onClearSearch) A custom builder for search app bar. Must return a widget that will replace default Giphy-like search bar input null. Displays default Giphy-like search bar input
GiphyClient giphyClient = GiphyClient(apiKey: "YOUR API KEY");
String randomId = await giphyClient.getRandomId();

Widgets

Optional but this widget is required if you get more gif's of user or view on Giphy following Giphy Design guidelines

giphy

GiphyGifWidget

Params

Value Type Description Default
gif required GiphyGif GiphyGif object from stream or JSON null
giphyGetWrapper required GiphyGetWrapper instance required for tap to more null
showGiphyLabel boolean show or hide Powered by GIPHYlabel at bottom true
borderRadius BorderRadius ex: BorderRadius.circular(10) add border radius to image null
imageAlignment Alignment this widget is a STACK with Image and tap buttons this property adjust alignment Alignment.center

GiphyGetWrapper

Params

Value Type Description Default
giphy_api_key required String Your Giphy API KEY null
builder function return Stream<GiphyGif> and Instance of GiphyGetWrapper null

Methods

void getGif(String queryText,BuildContext context)

return GiphyGetWrapper(
    giphy_api_key: REPLACE_WITH YOUR_API_KEY,
    // Builder with Stream<GiphyGif> and Instance of GiphyGetWrapper
    builder: (stream, giphyGetWrapper) => StreamBuilder<GiphyGif>(
      stream: stream,
      builder: (context, snapshot) {
        return Scaffold(
          body: snapshot.hasData
              ? SizedBox(
                // GiphyGifWidget with tap to more
                child: GiphyGifWidget(
                  imageAlignment: Alignment.center,
                  gif: snapshot.data,
                  giphyGetWrapper: giphyGetWrapper,
                  borderRadius: BorderRadius.circular(30),
                  showGiphyLabel: true,
                ),
              )
              : Text("No GIF"),
          floatingActionButton: FloatingActionButton(
            onPressed: () async {
              //Open Giphy Sheet
              giphyGetWrapper.getGif('', context);
            },
            tooltip: 'Open Sticker',
            child: Icon(Icons
                .insert_emoticon)),
        );
    })

    });

Example APP

First export your giphy api key

export GIPHY_API_KEY=YOUR_GIPHY_API_KEY

and ther run.

Contrib

Feel free to make any PR's

giphy_get's People

Contributors

bazookon avatar benco8186 avatar brazol avatar hellochunwei avatar itssidhere avatar mobisofts avatar orevial avatar sbis04 avatar scottwallace avatar seelrd avatar simplenotezy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

giphy_get's Issues

[Bug] TabBar texts not visible

When I run the example app on an iOS Simulator without Material3 turned on, the texts inside the TabBar are not visible in light mode (seems like they are white by default, and there's no way to pass a color property in the implementation to fix that).

Screenshot 2023-04-01 at 10 46 03 AM

Remove a Selected GIF From the UI

Thank you for making this plugin :) Is there an easy way to discard a selected GIF?

An example use case for this would be to display a selected GIF in the UI with a "remove" button next to it and to remove the selected GIF from the UI when that "remove" button is tapped.

Feature: get only GIFs

It would be nice with an option to hide the other tabs - such as sticker and emoji's. We are only interested in GIFs

RangeError When Loading Initial GIFs

Opening the Giphy sheet sometimes causes this exception when loading.

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (15444): The following RangeError was thrown building:
I/flutter (15444): RangeError (index): Invalid value: Valid value range is empty: 7
I/flutter (15444): 
I/flutter (15444): When the exception was thrown, this was the stack:
I/flutter (15444): #0      List.[] (dart:core-patch/growable_array.dart:254:60)
I/flutter (15444): #1      _GiphyTabDetailState.build.<anonymous closure> (package:giphy_get/src/views/tab/giphy_tab_detail.dart:130:34)
I/flutter (15444): #2      SliverChildBuilderDelegate.build (package:flutter/src/widgets/sliver.dart:455:22)
I/flutter (15444): #3      SliverVariableSizeBoxAdaptorElement._build.<anonymous closure> (package:flutter_staggered_grid_view/src/widgets/sliver.dart:154:38)
I/flutter (15444): #4      _HashMap.putIfAbsent (dart:collection-patch/collection_patch.dart:140:29)
I/flutter (15444): #5      SliverVariableSizeBoxAdaptorElement._build (package:flutter_staggered_grid_view/src/widgets/sliver.dart:153:26)
I/flutter (15444): #6      SliverVariableSizeBoxAdaptorElement.createChild.<anonymous closure> (package:flutter_staggered_grid_view/src/widgets/sliver.dart:164:55)
I/flutter (15444): #7      BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2535:19)
I/flutter (15444): #8      SliverVariableSizeBoxAdaptorElement.createChild (package:flutter_staggered_grid_view/src/widgets/sliver.dart:160:12)
I/flutter (15444): #9      RenderSliverVariableSizeBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter_staggered_grid_view/src/rendering/sliver_variable_size_box_adaptor.dart:252:23)
I/flutter (15444): #10     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1889:59)
I/flutter (15444): #11     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:912:15)
I/flutter (15444): #12     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1889:14)
I/flutter (15444): #13     RenderSliverVariableSizeBoxAdaptor._createOrObtainChild (package:flutter_staggered_grid_view/src/rendering/sliver_variable_size_box_adaptor.dart:240:5)
I/flutter (15444): #14     RenderSliverVariableSizeBoxAdaptor.addAndLayoutChild (package:flutter_staggered_grid_view/src/rendering/sliver_variable_size_box_adaptor.dart:317:5)
I/flutter (15444): #15     RenderSliverStaggeredGrid.performLayout (package:flutter_staggered_grid_view/src/rendering/sliver_staggered_grid.dart:336:17)
I/flutter (15444): #16     RenderObject.layout (package:flutter/src/rendering/object.dart:1779:7)
I/flutter (15444): #17     RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:137:12)
I/flutter (15444): #18     RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:371:11)
I/flutter (15444): #19     RenderObject.layout (package:flutter/src/rendering/object.dart:1779:7)
I/flutter (15444): #20     RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:510:13)
I/flutter (15444): #21     RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1574:12)
I/flutter (15444): #22     RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1483:20)
I/flutter (15444): #23     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1636:7)
I/flutter (15444): #24     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:881:18)
I/flutter (15444): #25     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:462:19)
I/flutter (15444): #26     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:876:13)
I/flutter (15444): #27     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:328:5)
I/flutter (15444): #28     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
I/flutter (15444): #29     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1082:9)
I/flutter (15444): #30     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:998:5)
I/flutter (15444): #34     _invoke (dart:ui/hooks.dart:163:10)
I/flutter (15444): #35     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:259:5)
I/flutter (15444): #36     _drawFrame (dart:ui/hooks.dart:126:31)
I/flutter (15444): (elided 3 frames from dart:async)

Trending Endpoint

It would be really great to request trending gifs with the endpoint they have in their SDK.

Also, it might be considerable to differentiate the command in the GiphyGet class so you can call GiphyGet.getTrends(), GiphyGet.search() or GiphyGet.byId().

Add Pull Request #36 to Add Debounce to Searches

Currently, search queries are executing with each keystroke. Added an optional parameter to GiphyGet.getGif called debounceTimeInMilliseconds defaulting to 350 milliseconds.

My search results were coming out strange. When I type "cabin", I get the results for the letter "C" for a while. Eventually it gives proper results for the chosen query, but the user is confused by the earlier partial queries.

Also, theoretically, it should make search results seem faster, as it's not doing the full work with each keystroke.

I have included a Debounce class that is self-disposing, and placed it in /lib/src/tools. I have also updated the documentation to reflect the change.

#36

Infinite loop on invalid text search

Hi, when I try to do search with invalid keyword and tap on keyboard enter the loader keeps on loading on and does not stop until we clear the text.

Thanks

Storing the GIFs

First of all, this plugin is amazing! My concern is, is it okay or is it ethical to store an selected gif object/URL in my backend database? If not, can anyone help me out with what can be an ethical solution for the same? Thanx in advance!

Dimming on scroll

When I scroll through the list, it dims the screen from time to time.
Seems to be the case when I loads more results...

Looks not so nice :(

Depnedency Constraints

Can you guys update the dependencies, because in my case version solving is getting failed again and again

Null Safety problems, not working

After upgrading myself to null-safety, and using the latest null-safety version for this package, now it breaks on opening, trying to cast a null to string while parsing Json internally:
type 'Null' is not a subtype of type 'String' in type cast #0 new GiphyPreviewImage.fromJson (package:giphy_get/src/client/models/image.dart:329:24) #1 new GiphyImages.fromJson (package:giphy_get/src/client/models/images.dart:100:31) #2 new GiphyGif.fromJson (package:giphy_get/src/client/models/gif.dart:66:27) #3 new GiphyCollection.fromJson.<anonymous closure> (package:giphy_get/src/client/models/collection.dart:13:60) #4 MappedListIterable.elementAt (dart:_internal/iterable.dart:411:31) #5 ListIterator.moveNext (dart:_internal/iterable.dart:340:26) #6 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27) #7 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28) #8 new List.of (dart:core-patch/array_patch.dart:50:28) #9 ListIterable.toList (dart:_internal/iterable.dart:211:44) #10 new GiphyCollection.fromJson (package:giphy_get/src/client/models/collection.dart:13:73) #11 GiphyClient._fetchCollection (package:giphy_get/src/client/client.dart:117:28) <asynchronous suspension> #12 _GiphyTabDetailState._loadMore (package:giphy_get/src/views/tab/giphy_tab_detail.dart:232:23) <asynchronous suspension>

Width calculation only is correct when the view takes up the whole width of the screen.

Nice work on the bottom modal.
There is an issue with the width calculation anytime the view doesn't take up the full screen (landscape tablets or web implementations). line 91 in giphy_tab_detail.dart is using (MediaQuery.of(context).size.width which is simply the width of the screen and not the width of the view. Using a LayoutBuilder to get the constraints maxwidth would fix this issue.

Screen Shot 2022-01-20 at 8 13 47 AM

v3.0.0 Emojis Crash

Emojis no longer load on v3.0.0 due to this error:

E/flutter (10673): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'int' in type cast
E/flutter (10673): #0      new GiphyPagination.fromJson (package:giphy_get/src/client/models/collection.dart:54:43)
E/flutter (10673): #1      new GiphyCollection.fromJson (package:giphy_get/src/client/models/collection.dart:17:33)
E/flutter (10673): #2      GiphyClient._fetchCollection (package:giphy_get/src/client/client.dart:117:28)
E/flutter (10673): <asynchronous suspension>
E/flutter (10673): #3      _GiphyTabDetailState._loadMore (package:giphy_get/src/views/tab/giphy_tab_detail.dart:209:21)
E/flutter (10673): <asynchronous suspension>
E/flutter (10673): 

writing integration tests with giphy get

Any ideas on how to write integration tests for widgets having giphy_get?

A normal flow would be like

  1. Clicking on a button
  2. Giphy get bottom sheet pops up
  3. Get GIFs/Images in View using Finder
  4. Click on a certain GIF

optional steps:

  1. Switching b/w GIFs/Stickers/Emojis tab
  2. Searching for gifs

Any tips would be helpful

Ability to share gifs to Social Media

This would be an excellent feature to add. In the meantime does anyone have a good idea how to do this? I've played around with downloading the gif and sharing via something like: https://pub.dev/packages/appinio_social_share
This results in only the first frame of the gif being uploaded as an image. So then I thought I guess I need to convert it to an mp4 first. This is most likely possible but does anyone have a better way?

Thanks!

GIPHY GET (NULL CHECK OPERATOR USED ON A NULL VALUE)

HAVING ISSUES WITH GIPHY GET (When getting only GIFs)

I have set up everything as the documentation on pub.dev stated.

Here is the main.dart file, exactly how it was written in the documentation.

MainDart

And Here is where i'm getting the GIFs. My API is working just fine, i'm able to get the GIPHY client random ID

carbon

But when i'm trying to access this, i'm getting an error, something about a NULL check on a NULL value

exception

And here's the error am getting on my Device 👇

Screenshot_20220725-112705

I'm running this application, on my Android Device, and everything else is working fine, i was using another GIPHY package (giphy_picker)
and it was and still working fine, decided to start using this package cuz it seem to be better than the other. So Help as fast as possible what can i do? to Fix this,

My Flutter and Dart Version 👇

Flutter 3.0.4 • channel stable • https://github.com/flutter/flutter.git Framework • revision 85684f9300 (4 weeks ago) • 2022-06-30 13:22:47 -0700 Engine • revision 6ba2af10bb Tools • Dart 2.17.5 • DevTools 2.12.2

[Question] Using cache network image package

I have a question. Why exactly is cached network image being used here as it will fill the cache without any way to clear that particular cache , also it adds a minimum 1.20.0 version restriction which is quiet unstable for now. I would propose to use extended_image or just no caching

Empty Emojis in web project

Hi I added the package to my flutter web project. It works nearly as expected. But the Emojis are only showing the loader. Any idea what is going wrong?

null-aware operation Warnings

I just upgraded to latest version and I am suddenly getting the warnings below

../../../../.pub-cache/hosted/pub.dartlang.org/giphy_get-3.0.4/lib/src/views/tab/giphy_tab_detail.dart:238:22: Warning: Operand of null-aware operation '!' has type 'List' which excludes null.

  • 'List' is from 'dart:core'.
  • 'GiphyGif' is from 'package:giphy_get/src/client/models/gif.dart' ('../../../../.pub-cache/hosted/pub.dartlang.org/giphy_get-3.0.4/lib/src/client/models/gif.dart').
    if (_collection!.data!.isNotEmpty && mounted) {
    ^
    ../../../../.pub-cache/hosted/pub.dartlang.org/giphy_get-3.0.4/lib/src/views/tab/giphy_tab_detail.dart:240:35: Warning: Operand of null-aware operation '!' has type 'List' which excludes null.
  • 'List' is from 'dart:core'.
  • 'GiphyGif' is from 'package:giphy_get/src/client/models/gif.dart' ('../../../../.pub-cache/hosted/pub.dartlang.org/giphy_get-3.0.4/lib/src/client/models/gif.dart').
    _list.addAll(_collection!.data!);

Allow for more customization

Right now giphy_get is great but the look and feel cannot be customized to match the app's brand.

Here is a screenshot with things that might be useful to customize:

Capture d’écran 2023-07-20 à 10 54 38

  • Modal handlebar
  • Search bar including :
    • search icon (the icon itself and its color)
    • text style (font, size, color, etc)
    • closing icon (the icon itself and its color)
  • GIF previews shapes (e.g. more or less rounded)
  • Text or widget "powered by GIPHY". It would be particulary useful to be able to replace this with a custom component to support translation

I know that package giphy_picker allows for more customization (but I can't use it because they don't allow opening the picker in a modal view and opens a new page instead), would it make sense to use the same types of optional builders for each part of the modal to build the modal with customized widgets ?

I could propose a PR for this, let me know

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.