import 'package:flutter/material.dart'; import '../models/serviceboy_model.dart'; class ServiceBoyProvider extends ChangeNotifier { List _serviceBoys = [ ServiceBoy(name: 'John Doe', phone: '9875643210'), ServiceBoy(name: 'Amit Raj', phone: '9765432180'), ServiceBoy(name: 'Manoj Sinha', phone: '9543219876'), ]; ServiceBoy? _selectedBoy; List get serviceBoys => _serviceBoys; ServiceBoy? get selectedBoy => _selectedBoy; // Add a new service boy void addServiceBoy(ServiceBoy boy) { _serviceBoys.add(boy); notifyListeners(); } // Edit an existing service boy void editServiceBoy(int index, ServiceBoy updatedBoy) { if (index >= 0 && index < _serviceBoys.length) { _serviceBoys[index] = updatedBoy; notifyListeners(); } } // Delete a service boy void deleteServiceBoy(int index) { if (index >= 0 && index < _serviceBoys.length) { _serviceBoys.removeAt(index); notifyListeners(); } } // Assign a selected service boy (for dialogs) void selectBoy(ServiceBoy boy) { _selectedBoy = boy; notifyListeners(); } void clearSelection() { _selectedBoy = null; notifyListeners(); } }