2 글 보임 - 1 에서 2 까지 (총 2 중에서)
-
글쓴이글
-
2023년 6월 8일 11:06 #86231
조성환참가자안녕하세요. 선생님 강의듣고 혼자 어플만드는데 막히는 부분이 있어서 질문 드립니다... 현상 : 1. 캐러셀 슬라이더를 사용해서 동적으로 캐러셀을 생성했습니다. 2. 리스트뷰빌더를 사용해서 캐러셀안에 아이템을 동적으로 생성하려 하였으나 전체 캐러셀에 동시에 적용됩니다. 3. 각각 캐러셀 안에 독립적으로 리스트뷰를 동적생성 하고싶습니다. 어떻게 수정해야할지 감이 안오네요 ㅠ
@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); }); }
)),
2023년 6월 8일 13:58 #86246
codingapple키 마스터외부패키지인거같은데 그거 사용법을 찾아봐야할듯요 현재 몇번째 슬라이드인지 알려주는 변수가 있을텐데 변수 == 0 이면 ListView 보여달라고 if문 써봅시다
-
글쓴이글
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
- 답변은 로그인 후 가능합니다.