작성
·
297
0
이렇게 하나의 사진만 뜨는데 강사님 코드와 어떤 부분이 차이가 있어서 그럴까요??
제껀 Flutter 버전 3 입니다
답변주시면 정말 감사하겠씁니다:)
import 'package:flutter/material.dart';
import '../model/model_movie.dart';
class BoxSlider extends StatelessWidget {
final List<Movie> movies;
BoxSlider({required this.movies, super.key});
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(7),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('지금뜨는 콘텐츠'),
Container(
height: 120,
child: ListView(
scrollDirection: Axis.horizontal,
children: makeBoxImage(movies),
),
)
],
),
);
}
}
List<Widget> makeBoxImage(List<Movie> movies) {
List<Widget> results =[];
for (var i=0; i<movies.length; i++){
results.add(
InkWell(
onTap: () {},
child: Container(
padding: EdgeInsets.only(right: 10),
child: Align(
alignment: Alignment.centerLeft,
child: Image.asset('assets/${movies[i].poster}'),
),
),
)
);
}
return results;
}
답변