-
-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Labels
Description
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

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