Initial commit for complete UI
This commit is contained in:
48
lib/provider/serviceboy_provider.dart
Normal file
48
lib/provider/serviceboy_provider.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/serviceboy_model.dart';
|
||||
|
||||
class ServiceBoyProvider extends ChangeNotifier {
|
||||
List<ServiceBoy> _serviceBoys = [
|
||||
ServiceBoy(name: 'John Doe', phone: '9875643210'),
|
||||
ServiceBoy(name: 'Amit Raj', phone: '9765432180'),
|
||||
ServiceBoy(name: 'Manoj Sinha', phone: '9543219876'),
|
||||
];
|
||||
|
||||
ServiceBoy? _selectedBoy;
|
||||
|
||||
List<ServiceBoy> 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user