6-3.(p.92)lib/photo.dart


lib/photo.dart

class Photo {
  // ...

  // お気に入り登録状況を切り替える
  Photo toggleIsFavorite() {
    return Photo(
      id: id,
      imageURL: imageURL,
      imagePath: imagePath,
      isFavorite: !isFavorite,
      createdAt: createdAt,
    );
  }
}