Skip to content

Commit 9a52d95

Browse files
committed
Update list_actors.dart
1 parent fd4d783 commit 9a52d95

File tree

1 file changed

+48
-49
lines changed

1 file changed

+48
-49
lines changed
Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,63 @@
11
import 'package:flutter/material.dart';
22

33
class Actor {
4-
Actor({required this.imageUrl, required this.name, required this.id});
4+
Actor({
5+
required this.imageUrl,
6+
required this.name,
7+
required this.id,
8+
});
59
String imageUrl;
610
String name;
711
String id;
812
}
913

10-
class ListActors extends StatefulWidget {
11-
const ListActors({super.key, required this.actors, required this.title});
14+
class ListActors extends StatelessWidget {
15+
const ListActors({
16+
super.key,
17+
required this.actors,
18+
required this.title,
19+
});
1220
final List<Actor> actors;
1321
final String title;
1422

15-
@override
16-
State<ListActors> createState() => _ListActorsState();
17-
}
18-
19-
class _ListActorsState extends State<ListActors> {
20-
_buildActor(Actor actor) {
21-
return SizedBox(
22-
width: 100,
23-
child: Column(
24-
mainAxisAlignment: MainAxisAlignment.start,
25-
crossAxisAlignment: CrossAxisAlignment.center,
26-
children: [
27-
CircleAvatar(
28-
radius: 30,
29-
child: ClipOval(child: Image.network(actor.imageUrl))),
30-
Text(
31-
actor.name,
32-
overflow: TextOverflow.ellipsis,
33-
)
34-
]));
35-
}
36-
37-
_buildActorsList() {
38-
return SizedBox(
39-
height: 125,
40-
child: Column(
41-
mainAxisAlignment: MainAxisAlignment.start,
42-
crossAxisAlignment: CrossAxisAlignment.start,
43-
children: [
44-
Text(
45-
widget.title,
46-
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
47-
),
48-
Expanded(
49-
child: ListView.builder(
50-
scrollDirection: Axis.horizontal,
51-
itemBuilder: (context, index) {
52-
return _buildActor(widget.actors[index]);
53-
},
54-
itemCount: widget.actors.length,
55-
))
56-
],
57-
));
58-
}
59-
6023
@override
6124
Widget build(BuildContext context) {
62-
return _buildActorsList();
25+
return SizedBox(
26+
height: 125,
27+
child: Column(
28+
mainAxisAlignment: MainAxisAlignment.start,
29+
crossAxisAlignment: CrossAxisAlignment.start,
30+
children: [
31+
Text(
32+
title,
33+
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
34+
),
35+
Expanded(
36+
child: ListView.builder(
37+
scrollDirection: Axis.horizontal,
38+
itemBuilder: (context, index) {
39+
final actor = actors[index];
40+
return SizedBox(
41+
width: 100,
42+
child: Column(
43+
mainAxisAlignment: MainAxisAlignment.start,
44+
crossAxisAlignment: CrossAxisAlignment.center,
45+
children: [
46+
CircleAvatar(
47+
radius: 30,
48+
child: ClipOval(child: Image.network(actor.imageUrl))),
49+
Text(
50+
actor.name,
51+
overflow: TextOverflow.ellipsis,
52+
)
53+
],
54+
),
55+
);
56+
},
57+
itemCount: actors.length,
58+
))
59+
],
60+
),
61+
);
6362
}
6463
}

0 commit comments

Comments
 (0)