Skip to content

Add item index support  #83

@AfroCyberGuy

Description

@AfroCyberGuy

Platforms

dart

Description

Can we add a feature to accept an optional index on the like button it helps when we want to do a request that required to get the item liked i.e in this case with an index. because onTap: Future<bool?> Function(bool)? onTap function is very limited i will be happy to contribute.

Why

Screenshot 2024-02-20 at 10 11 00
 child: RecommendedCard(
                            width: getScreenWidth(context) / 2.5,
                            height: getScreenWidth(context) / 2.5,
                            image: '$imageBaseUrl/${event.image}',
                            tagText: event.category?.name ?? '',
                            titleText: event.title ?? '',
                            dateText: event.date ?? '',
                            onLike: () async {
                              await notifier.like(event.id ?? 0, index);
                            },
                            isFavourite: event.isliked ?? 0,
                           //onLikeButtonTapped does a request and it needs and index button like button only accept this function type[ Future<bool?> Function(bool)? onTap ]
                            onTap: notifier.onLikeButtonTapped,
                          ),
                        );
                      },
                    ),
                    
                //This is my controller with notifier.onLikeButtonTapped method
                 //This is the function accepted by LikeButton , so its limited i can get an object tapped so that i can do a proper request
                      Future<bool> onLikeButtonTapped(bool isLiked) async {
    int likeStatus = 0;

    setLikingStatus(true);
    state = state.copyWith(likeEventResult: const AsyncValue.loading());

    final result = await _recommendedEventsServiceImpl.like(
      LikeRequest(
        eventId: state.eventId,
        userId: int.parse(_preferencesNotifier.getUserID()),
      ),
    );

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions