import 'package:flutter/material.dart'; import '/data/models/contact_model.dart'; import '/data/repositories/contact_repository.dart'; class ContactProvider extends ChangeNotifier { final ContactRepository _repository = ContactRepository(); List _contacts = []; bool _isLoading = false; String? _error; int? _currentUserId; List get contacts => _contacts; bool get isLoading => _isLoading; String? get error => _error; void setCurrentUserId(int? id) { _currentUserId = id; notifyListeners(); } Future loadContacts() async { _isLoading = true; _error = null; notifyListeners(); try { final allContacts = await _repository.fetchContacts(); _contacts = allContacts.where((contact) => contact.id != _currentUserId).toList(); } catch (e) { _error = e.toString(); } finally { _isLoading = false; notifyListeners(); } } }