26 lines
666 B
Dart
26 lines
666 B
Dart
import 'package:bloc/bloc.dart';
|
|
import 'package:dio/dio.dart';
|
|
import 'package:equatable/equatable.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:hoshan/data/model/event_model.dart';
|
|
import 'package:hoshan/data/repository/bot_repository.dart';
|
|
|
|
part 'cmp_state.dart';
|
|
|
|
class CmpCubit extends Cubit<CmpState> {
|
|
CmpCubit() : super(CmpInitial());
|
|
|
|
void getAllEvents() async {
|
|
emit(CmpLoading());
|
|
try {
|
|
final response = await BotRepository.getAllEvents();
|
|
emit(CmpSuccess(event: response));
|
|
} on DioException catch (e) {
|
|
emit(CmpFail());
|
|
if (kDebugMode) {
|
|
print('Dio Error is: $e');
|
|
}
|
|
}
|
|
}
|
|
}
|