42 lines
1.1 KiB
Dart
42 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class UserProvider extends ChangeNotifier {
|
|
String? _uid;
|
|
String? _firstName;
|
|
String? _lastName;
|
|
String? _role;
|
|
String? _profilePictureUrl;
|
|
String? _email;
|
|
String? _phoneNumber;
|
|
|
|
String? get uid => _uid;
|
|
String? get firstName => _firstName;
|
|
String? get lastName => _lastName;
|
|
String? get role => _role;
|
|
String? get profilePhotoUrl => _profilePictureUrl;
|
|
String? get email => _email;
|
|
String? get phoneNumber => _phoneNumber;
|
|
|
|
void setUserData(Map<String, dynamic> userData, String uid) {
|
|
_uid = uid;
|
|
_firstName = userData['firstName'];
|
|
_lastName = userData['lastName'];
|
|
_role = userData['role'] ?? 'USER'; // Default role if not provided
|
|
_profilePictureUrl = userData['profilePhotoUrl'];
|
|
_email = userData['email'];
|
|
_phoneNumber = userData['phoneNumber'];
|
|
notifyListeners(); // Notify listeners that state has changed
|
|
}
|
|
|
|
void clearUserData() {
|
|
_uid = null;
|
|
_firstName = null;
|
|
_lastName = null;
|
|
_role = null;
|
|
_profilePictureUrl = null;
|
|
_email = null;
|
|
_phoneNumber = null;
|
|
notifyListeners();
|
|
}
|
|
}
|