게시글
질문&답변
2020.07.27
포스터 이미지 삽입했는데 오류뜨네요..
따라치며 클론해본 CarouselImage 클래스 입니다. import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; import 'package:netflix_clone_practice/model/movie_model.dart'; class CarouselImage extends StatefulWidget { final ListMovie> movies; CarouselImage({this.movies}); @override _CarouselImageState createState() => _CarouselImageState(); } class _CarouselImageState extends StateCarouselImage> { ListMovie> movies; ListWidget> images; ListString> keywords; Listbool> likes; int _currentPage = 0; String _currentKeyword; @override void initState() { super.initState(); movies = widget.movies; // Q. 여기서 widget은 어디로부터 온 것일까? images = movies.map((m) => Image.asset(m.poster)).toList(); keywords = movies.map((m) => m.keyword).toList(); likes = movies.map((m) => m.like).toList(); _currentKeyword = keywords[0]; } Widget build(BuildContext context) { return Container( child: Column( children: Widget>[ Container( padding: EdgeInsets.all(20), ), CarouselSlider( items: images, options: CarouselOptions( onPageChanged: (index, reason) { setState(() { _currentPage = index; _currentKeyword = keywords[_currentPage]; }); }, ), ), Container( padding: EdgeInsets.fromLTRB(0, 10, 0, 3), child: Text( _currentKeyword, style: TextStyle(fontSize: 11), ), ), Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: Widget>[ Container( child: Column( children: Widget>[ likes[_currentPage] ? IconButton( icon: Icon(Icons.check), onPressed: () {}, ) : IconButton( icon: Icon(Icons.add), onPressed: () {}, ), Text( '내가 찜한 콘텐츠', style: TextStyle(fontSize: 11), ) ], ), ), Container( padding: EdgeInsets.only(right: 10), child: FlatButton( color: Colors.white, onPressed: () {}, child: Row( children: Widget>[ Icon( Icons.play_arrow, color: Colors.black, ), Padding( padding: EdgeInsets.all(3), ), Text( '재생', style: TextStyle(color: Colors.black), ), ], ), ), ), Container( padding: EdgeInsets.only(right: 10), child: Column( children: Widget>[ IconButton( icon: Icon(Icons.info), onPressed: () {}, ), Text( '정보', style: TextStyle(fontSize: 11), ), ], ), ), ], ), ), Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: makeIndicator(likes, _currentPage), ), ), ], ), ); } } ListWidget> makeIndicator(List list, int _currentPage) { ListWidget> results = []; for (var i = 0; i results.add( Container( width: 8, height: 8, margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 2.0), decoration: BoxDecoration( shape: BoxShape.circle, color: _currentPage == i ? Color.fromRGBO(255, 255, 255, 0.9) : Color.fromRGBO(255, 255, 255, 0.4), ), ), ); } return results; }
- 0
- 4
- 389
질문&답변
2020.07.27
포스터 이미지 삽입했는데 오류뜨네요..
(사진) 뒷 강의까지 진행해보았는데 CircleSlider로는 정상적으로 이미지 출력이 되는데 CarouselImage에서 오류가 있는걸까요?..
- 0
- 4
- 389