import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../shared/models/user.dart'; import 'profile_service.dart'; class ProfileNotifier extends StateNotifier> { final ProfileService _service; ProfileNotifier(this._service) : super(const AsyncValue.loading()) { load(); } Future load() async { state = const AsyncValue.loading(); state = await AsyncValue.guard(() => _service.getProfile()); } Future update(UpdateProfileRequest req) async { try { final updated = await _service.updateProfile(req); state = AsyncValue.data(updated); return true; } catch (_) { return false; } } } final profileProvider = StateNotifierProvider>( (ref) => ProfileNotifier(ref.read(profileServiceProvider)), );