This repository has been archived on 2024-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
dialer/lib/pages/contact.dart
2024-10-25 12:26:44 +01:00

42 lines
1.1 KiB
Dart

// contact.dart
import 'package:flutter/material.dart';
import 'package:dialer/classes/contactClass.dart';
import 'package:dialer/classes/displayContact.dart';
class ContactPage extends StatefulWidget {
const ContactPage({super.key});
@override
_ContactPageState createState() => _ContactPageState();
}
class _ContactPageState extends State<ContactPage> {
@override
Widget build(BuildContext context) {
// Optionally sort contacts alphabetically
final sortedContacts = [...contacts]..sort((a, b) => a.name.compareTo(b.name));
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: const Text('Contacts'),
),
body: ListView.builder(
itemCount: sortedContacts.length,
itemBuilder: (context, index) {
return DisplayContact(contact: sortedContacts[index]);
},
),
);
}
}
List<Contact> contacts = [
Contact('Alice', '1234567890'),
Contact('Bob', '0987654321', isFavorite: true, isLocked: true, publicKey: 'AB...YZ'),
Contact('Charlie', '5555555555', isLocked: true),
];