forked from ECellNitrr/ECellOfficialApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsponsors_cubit.dart
29 lines (27 loc) · 1.08 KB
/
sponsors_cubit.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import 'package:bloc/bloc.dart';
import 'package:ecellapp/core/res/errors.dart';
import 'package:ecellapp/core/res/strings.dart';
import 'package:ecellapp/core/utils/logger.dart';
import 'package:ecellapp/models/sponsor_category.dart';
import 'package:ecellapp/screens/sponsors/sponsors_repository.dart';
import 'package:equatable/equatable.dart';
part 'sponsors_state.dart';
class SponsorsCubit extends Cubit<SponsorsState> {
final SponsorsRepository _sponsorsRepository;
SponsorsCubit(this._sponsorsRepository) : super(SponsorsInitial());
Future<void> getSponsorsList() async {
try {
emit(SponsorsLoading());
List<SponsorCategory> speakerList = await _sponsorsRepository.getAllSponsors();
emit(SponsorsSuccess(speakerList));
} on NetworkException {
emit(SponsorsError(S.networkException));
} on ValidationException catch (e) {
emit(SponsorsError(e.description));
} on UnknownException {
emit(SponsorsError(S.unknownException));
} catch (e) {
Log.s(tag: "Speaker Cubit", message: "Unknown Error message:" + e.toString());
}
}
}