import 'dart:io'; import 'package:flutter/material.dart'; import '../models/user_profile.dart'; import '../services/user_profile_service.dart'; class UserProfileProvider extends ChangeNotifier { UserProfileService? _service; UserProfile? profile; bool loading = false; void init(BuildContext context) { _service = UserProfileService(context); } Future loadProfile(BuildContext context) async { _service ??= UserProfileService(context); loading = true; notifyListeners(); final res = await _service!.getProfile(); if (res['success'] == true) { profile = UserProfile.fromJson(res['data']); } loading = false; notifyListeners(); } Future updateProfileImage(BuildContext context, File image) async { _service ??= UserProfileService(context); loading = true; notifyListeners(); final res = await _service!.updateProfileImage(image); if (res['success'] == true) { profile = UserProfile.fromJson(res['data']); loading = false; notifyListeners(); return true; } loading = false; notifyListeners(); return false; } /// NEW: Send profile update request (admin approval required) Future sendProfileUpdateRequest( BuildContext context, Map data, ) async { _service ??= UserProfileService(context); loading = true; notifyListeners(); final res = await _service!.sendUpdateRequest(data); loading = false; notifyListeners(); return res['success'] == true; } }