2024-10-10 05:49:33 +00:00
|
|
|
import 'package:english_learning/core/services/repositories/section_repository.dart';
|
|
|
|
|
import 'package:english_learning/features/learning/modules/model/section_model.dart';
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
|
|
|
|
|
class SectionProvider extends ChangeNotifier {
|
|
|
|
|
final SectionRepository _repository = SectionRepository();
|
|
|
|
|
List<Section> _sections = [];
|
|
|
|
|
bool _isLoading = false;
|
Updated various files, including constants, exercise providers, question widgets, section models, and screens for topics, learning, and settings, with changes to URLs, error handling, and UI components.
2024-11-21 05:45:41 +00:00
|
|
|
dynamic _error;
|
2024-10-10 05:49:33 +00:00
|
|
|
|
|
|
|
|
List<Section> get sections => _sections;
|
|
|
|
|
bool get isLoading => _isLoading;
|
|
|
|
|
String? get error => _error;
|
|
|
|
|
|
2024-10-23 04:16:07 +00:00
|
|
|
Future<List<Section>> fetchSections(String token) async {
|
2024-10-10 05:49:33 +00:00
|
|
|
try {
|
|
|
|
|
_sections = await _repository.getSections(token);
|
|
|
|
|
notifyListeners();
|
2024-10-23 04:16:07 +00:00
|
|
|
return _sections;
|
2024-10-10 05:49:33 +00:00
|
|
|
} catch (e) {
|
|
|
|
|
_error = e.toString();
|
|
|
|
|
notifyListeners();
|
2024-10-23 04:16:07 +00:00
|
|
|
return [];
|
2024-10-10 05:49:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|