• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Flutter 게시판 캐러셀 슬라이더와 리스트뷰빌더 아이템 중복

캐러셀 슬라이더와 리스트뷰빌더 아이템 중복

  • 이 주제에는 1개 답변, 2명 참여가 있으며 codingapple2 년 전에 전에 마지막으로 업데이트했습니다.
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 글쓴이
  • #86231

    조성환
    참가자
    안녕하세요.
    선생님 강의듣고 혼자 어플만드는데 막히는 부분이 있어서 질문 드립니다...
    
    현상 : 
    1. 캐러셀 슬라이더를 사용해서 동적으로 캐러셀을 생성했습니다.
    2. 리스트뷰빌더를 사용해서 캐러셀안에 아이템을 동적으로 생성하려 하였으나 전체 캐러셀에 동시에 적용됩니다.
    3. 각각 캐러셀 안에 독립적으로 리스트뷰를 동적생성 하고싶습니다.
    어떻게 수정해야할지 감이 안오네요 ㅠ 
    
    KakaoTalk_Photo_2023-06-08-10-59-44 001KakaoTalk_Photo_2023-06-08-10-59-44 002
    
    @override
    Widget build(BuildContext context) {
      return Container(
        color: Color(0xff181420),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            CarouselSlider.builder(
                itemCount: context.read<store>().myWorkList.length,
                itemBuilder: (c,i,r){
                  return Container(
                    padding: EdgeInsets.all(10),
                    width: double.infinity,
                    margin: EdgeInsets.all(10),
                    decoration: BoxDecoration(
                      color: Color(0xff181420),
                      borderRadius: BorderRadius.circular(10),
                    ),
                    child: Column(
                      children: [
                        Container(
                          child: Text(context.read<store>().myWorkList[i]['name'],style: TextStyle(color: Color(0xff0075ff)),),
                        ),
                        Container(
                          height: 400,
                          child: ListView.builder(
                              itemCount: setCount,
                              itemBuilder: (c,i1){
                                return SizedBox(
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                    children: [
                                      Text('${i1+1}세트',style: TextStyle(fontSize: 24,color: Colors.white),),
                                      Text('5kg',style: TextStyle(fontSize: 24,color: Colors.white),),
                                      Text('10회',style: TextStyle(fontSize: 24,color: Colors.white),),
                                      SizedBox(),
                                      IconButton(onPressed: (){
                                        setState(() {
                                          setCount++;
                                          print('${setCount}추가');
                                        });
                                      }, icon: Icon(CupertinoIcons.checkmark_alt,size: 34,color: Color(0xff0075ff))),
                                      Text('|',style: TextStyle(color: Color(0xff626877)),),
                                      IconButton(onPressed: (){
                                        setState(() {
                                          setCount--;
                                          print('${setCount}제거');
                                        });
                                      }, icon: Icon(CupertinoIcons.minus,size: 34,color: Colors.red)),
                                    ],
                                  ),
                                );
                              }),
                        )
                      ],
                    ),
                  );
                },
                options: CarouselOptions(
                  height: 500,
                  viewportFraction: 1,
                  initialPage: 0,
                  reverse: false,
                  scrollDirection: Axis.horizontal,
                  enableInfiniteScroll: false,
                  onPageChanged:(i,r){
                    setState(() {
                      _currentCarousel = i;
                      print(_currentCarousel);
                    });
                  }
                )),
    #86246

    codingapple
    키 마스터
    외부패키지인거같은데 그거 사용법을 찾아봐야할듯요 
    현재 몇번째 슬라이드인지 알려주는 변수가 있을텐데 
    변수 == 0 이면 ListView 보여달라고 if문 써봅시다
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠