import 'package:wanisclient/models/NotificationModelFCM.dart'; import 'package:wanisclient/services/NotificationService.dart'; import 'package:flutter/material.dart'; import '../models/notification_model.dart'; class NotificationFCMProvider with ChangeNotifier { final NotificationFCMService _service = NotificationFCMService(); List _notifications = []; bool _isLoading = false; int _page = 0; final int _size = 10; int _totalPages = 1; List get notifications => _notifications; bool get isLoading => _isLoading; bool get hasMore => _page < _totalPages; Future fetchNotifications({bool loadMore = false}) async { if (_isLoading) return; _isLoading = true; notifyListeners(); if (!loadMore) { _page = 0; _notifications.clear(); } final response = await _service.fetchNotificationsFCM( page: _page, size: _size, ); print("===================55========> ${response.data} "); print("===================66========> ${response.statusCode} "); if (response.isValidResponse && response.data != null) { final newNotifications = response.data!; _notifications.addAll(newNotifications); _totalPages = response.totalPages ?? 1; _page++; print("=======================////====> $response "); } _isLoading = false; notifyListeners(); } void reset() { _notifications.clear(); _page = 0; _totalPages = 1; notifyListeners(); } }