커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
하트가 안변하는 이유좀요!!
앱개발 종합반 - 플러터
2주차
북마크
조*준
댓글
1
추천
0
조회수
7
조회수
7
답변 완료
스파르타 즉문즉답

main.dart

(저기 파란줄 뜨는게 문제인가요?)

스파르타 즉문즉답


feed.dart


import 'package:flutter/cupertino.dart';

import 'package:flutter/material.dart';


class Feed extends StatefulWidget {

  const Feed({

    Key? key,

  }) : super(key: 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: [

        // CilpRRect 를 통해 이미지에 곡선 border 생성

        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
댓글 알림
나의얼굴