import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../services/auth_service.dart'; class AuthProvider with ChangeNotifier { final AuthService _authService = AuthService(); bool _isLoading = false; String? _error; bool get isLoading => _isLoading; String? get error => _error; Future login(String email, String password) async { _isLoading = true; _error = null; notifyListeners(); final result = await _authService.login(email, password); _isLoading = false; if (result['success']) { notifyListeners(); return true; } else { _error = result['message']; notifyListeners(); return false; } } Future signup(Map data) async { _isLoading = true; _error = null; notifyListeners(); final result = await _authService.signup(data); _isLoading = false; if (result['success']) { notifyListeners(); return true; } else { _error = result['message']; notifyListeners(); return false; } } Future logout() async { final prefs = await SharedPreferences.getInstance(); await prefs.remove('token'); await prefs.remove('user_details'); await prefs.remove('user_email'); await prefs.remove('payment_session'); notifyListeners(); } }