커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
아이콘 색상 변경 질문 드립니다.
[왕초보] 플러터(Flutter)로 시작하는 앱개발 종합반 v0
0주차
북마크
황*아
댓글
4
추천
0
조회수
18
조회수
18
답변 완료


왕초보 플러터 앱개발 2-6 수강중입니다.

하트 아이콘 클릭 시 하트 색상 변경이 안되어 질문 드립니다.

클릭했을 때 클릭이 되고 있는 표시? 도 안 뜨고 색상 변경도 되지 않습니다.

onTap에 print 코드도 넣어보았는데 실행이 안되네요ㅜ

구글링도 해보았는데 어디가 문제인지를 몰라서 해결을 못하고 있습니다!


feed.dart의 코드입니다.

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';


class Feed extends StatefulWidget {
  const Feed({
    super.key,
  });


  @override
  State<Feed> createState() => _FeedState();
}


class _FeedState extends State<Feed> {
  bool isFavorite = false;


  @override
  Widget build(BuildContext context) {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        ClipRRect(
          borderRadius: BorderRadius.circular(8),
          child: Image.network(
            'https://cdn2.thecatapi.com/images/6bt.jpg',
            width: 100,
            height: 100,
            fit: BoxFit.cover,
          ),
        ),
        SizedBox(width: 12),
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                'M1 아이패드 프로 11형(3세대) 와이파이 128G 팝니다.',
                style: TextStyle(
                  fontSize: 16,
                  color: Colors.black,
                ),
                softWrap: false,
                maxLines: 2, 
                overflow: TextOverflow.ellipsis,
              ),
              SizedBox(height: 2), 
              Text(
                '봉천동 · 6분 전',
                style: TextStyle(
                  fontSize: 12,
                  color: Colors.black45,
                ),
              ),
              SizedBox(height: 4),
              Text(
                '100만원',
                style: TextStyle(
                  fontSize: 14,
                  fontWeight: FontWeight.bold,
                ),
              ),
              Row(
                children: [
                  Spacer(), 
                  GestureDetector(
                    onTap: () {
                      setState(() {
                        isFavorite = !isFavorite; 
                      });
                    },
                    child: Row(
                      children: [
                        Icon(
                          isFavorite
                              ? CupertinoIcons.heart_fill 
                              : CupertinoIcons.heart, 
                          color: isFavorite ? Colors.pink : Colors.black,
                          size: 16,
                        ),
                        Text(
                          '1',
                          style: TextStyle(color: Colors.black54),
                        ),
                      ],
                    ),
                  )
                ],
              ),
            ],
          ),
        ),
      ],
    );
  }
}





취소
 공유
취소
댓글 0
댓글 알림
나의얼굴