28 lines
841 B
Dart
28 lines
841 B
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:initial_folder/models/lesson_model.dart';
|
|
import 'package:initial_folder/providers/lesson_course_provider.dart';
|
|
import 'package:initial_folder/services/current_lesson_service.dart';
|
|
|
|
class CurrentLessonProvider extends ChangeNotifier {
|
|
late LessonModel _currentLesson;
|
|
LessonModel get payload => _currentLesson;
|
|
|
|
ResultState _state = ResultState.loading;
|
|
ResultState get state => _state;
|
|
|
|
Future<dynamic> fetchCurrentLesson(String lessonId) async {
|
|
_state = ResultState.loading;
|
|
notifyListeners();
|
|
|
|
try {
|
|
final data = await CurrentLessonService().getCurrentLesson(lessonId);
|
|
_currentLesson = data;
|
|
_state = ResultState.hasData;
|
|
notifyListeners();
|
|
} catch (e) {
|
|
_state = ResultState.error;
|
|
notifyListeners();
|
|
}
|
|
}
|
|
}
|