fix: notify immediately when isLoading=true in service fetch methods
Without notifyListeners() after isLoading=true, the Consumer would briefly show stale data (or 'service not found') from a previous navigation before the API call completes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
ea442aafa7
commit
aa7b890ce4
@@ -66,6 +66,7 @@ class ServicesProvider extends ChangeNotifier {
|
|||||||
getServiceForUser(String serviceId) async {
|
getServiceForUser(String serviceId) async {
|
||||||
try {
|
try {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
notifyListeners();
|
||||||
final data = await _api.get('/services/$serviceId');
|
final data = await _api.get('/services/$serviceId');
|
||||||
final map = data as Map<String, dynamic>;
|
final map = data as Map<String, dynamic>;
|
||||||
final servicio = Service.fromJson(map, map['id'] as String);
|
final servicio = Service.fromJson(map, map['id'] as String);
|
||||||
@@ -90,6 +91,7 @@ class ServicesProvider extends ChangeNotifier {
|
|||||||
getServiceForProfessional(String serviceId) async {
|
getServiceForProfessional(String serviceId) async {
|
||||||
try {
|
try {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
notifyListeners();
|
||||||
final data = await _api.get('/services/$serviceId');
|
final data = await _api.get('/services/$serviceId');
|
||||||
final map = data as Map<String, dynamic>;
|
final map = data as Map<String, dynamic>;
|
||||||
final servicio = Service.fromJson(map, map['id'] as String);
|
final servicio = Service.fromJson(map, map['id'] as String);
|
||||||
|
|||||||
Reference in New Issue
Block a user