Skip to content

HeartOverlayAnimator appearing on all images/posts in list view. #7

@githubaamod

Description

@githubaamod

Hi,

I am using this HeartOverlayAnimator in my project. Expected result is this effect must display only on image/post which user will like(double tap). When i double tap on image/post this icon is appearing on all images/posts. I already have like button implemented and only need this HeartOverlayAnimator effect when user like any post/image.

I have used HeartOverlayAnimator like below.

import 'package:cmpic/widgets/heartoverlay.dart';
final StreamController<void> _doubleTapImageEvents =
    StreamController.broadcast();

i have a function which handles like event. In that function i have written this.

 if (_isLiked) // display overlay only for Like event and not for Unlike.
_doubleTapImageEvents.sink.add(null);

below is my gesture detector for post/images.

GestureDetector(
                          onDoubleTap: () => handleLikePost(products[index]),
                          child: Stack(
                            alignment: Alignment.center,
                            children: <Widget>[
                              CachedNetworkImage(
                                width: MediaQuery.of(context).size.width - 2,
                                imageUrl: products[index].entryimgpathbig,
                                placeholder: (context, url) =>
                                    new CircularProgressIndicator(),
                                errorWidget: (context, url, error) =>
                                    new Icon(Icons.error),
                              ),

                              HeartOverlayAnimator(
                                  triggerAnimationStream:
                                      _doubleTapImageEvents.stream),
                            ],
                          ),
                        ),

is there anything i am missing or implementing wrong? Please let me know how to display this effect on only images/post which user has doubletapped/liked.

thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions