26 lines
708 B
Dart
26 lines
708 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/photo_gen_model.dart';
|
|
import 'package:hoshan/data/repository/bot_repository.dart';
|
|
|
|
part 'persons_state.dart';
|
|
|
|
class PersonsCubit extends Cubit<PersonsState> {
|
|
PersonsCubit() : super(PersonsInitial());
|
|
|
|
void getCharacters() async {
|
|
emit(PersonsLoading());
|
|
try {
|
|
final response = await BotRepository.getAllCharachters();
|
|
emit(PersonsSuccess(chars: response));
|
|
} on DioException catch (e) {
|
|
emit(PersonsFail());
|
|
if (kDebugMode) {
|
|
print('Dio Error is: $e');
|
|
}
|
|
}
|
|
}
|
|
}
|