Initial commit: Penyerahan final Source code Tugas Akhir
This commit is contained in:
27
lib/providers/current_lesson_provider.dart
Normal file
27
lib/providers/current_lesson_provider.dart
Normal file
@ -0,0 +1,27 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user