LCOV - code coverage report
Current view: top level - src/favorites/presentation/widgets - favorite_movie.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 12 12 100.0 %
Date: 2026-03-02 18:37:46 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:tech_proof/domain/entities/movie_entity.dart';
       2             : import 'package:tech_proof/src/favorites/presentation/bloc/favorites_bloc.dart';
       3             : import 'package:flutter/material.dart';
       4             : import 'package:flutter_bloc/flutter_bloc.dart';
       5             : 
       6             : class FavoriteMovie extends StatelessWidget {
       7             :   final MovieEntity movie;
       8           2 :   const FavoriteMovie({super.key, required this.movie});
       9             : 
      10           2 :   @override
      11             :   Widget build(BuildContext context) {
      12             :     bool isFavorite = false;
      13           2 :     return BlocBuilder<FavoritesBloc, FavoritesState>(
      14           2 :       builder: (context, state) {
      15           2 :         if (state is FavoritesLoaded) {
      16             :           FavoritesLoaded currentState = state;
      17           4 :           isFavorite = currentState.favoriteMovies.any(
      18           5 :             (favMovie) => favMovie.id == movie.id,
      19             :           );
      20             :         }
      21           2 :         return FloatingActionButton(
      22           1 :           onPressed: () {
      23             :             !isFavorite
      24           4 :                 ? context.read<FavoritesBloc>().add(AddFavoriteMovie(movie))
      25           4 :                 : context.read<FavoritesBloc>().add(RemoveFavoriteMovie(movie));
      26             :           },
      27           2 :           child: Icon(isFavorite ? Icons.favorite : Icons.favorite_border),
      28             :         );
      29             :       },
      30             :     );
      31             :   }
      32             : }

Generated by: LCOV version 1.14