43 lines
951 B
Dart
43 lines
951 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class FriendItem {
|
|
final String name;
|
|
final Widget place;
|
|
|
|
FriendItem(this.name, this.place);
|
|
|
|
Widget buildTitle(BuildContext context) {
|
|
return Text(name);
|
|
}
|
|
|
|
Widget returnIcon(BuildContext context) {
|
|
return place;
|
|
}
|
|
}
|
|
|
|
class ListViewController extends StatelessWidget {
|
|
ListViewController({
|
|
Key? key,
|
|
}) : super(key: key);
|
|
|
|
final friends = List<FriendItem>.generate(
|
|
100,
|
|
(i) => i % 2 == 0
|
|
? FriendItem('Person $i', const Icon(Icons.home))
|
|
: FriendItem('Person $i', const Icon(Icons.business_center)));
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Expanded(
|
|
child: ListView.builder(
|
|
itemCount: friends.length,
|
|
itemBuilder: (context, index) {
|
|
return ListTile(
|
|
leading: friends[index].place,
|
|
title: friends[index].buildTitle(context));
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|