26 lines
705 B
Dart
26 lines
705 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/banner_model.dart';
|
|
import 'package:hoshan/data/repository/chatbot_repository.dart';
|
|
|
|
part 'banners_state.dart';
|
|
|
|
class BannersCubit extends Cubit<BannersState> {
|
|
BannersCubit() : super(BannersInitial());
|
|
|
|
void getBanners() async {
|
|
emit(BannersLoading());
|
|
try {
|
|
final response = await ChatbotRepository.getBanners();
|
|
emit(BannersSuccess(banners: response));
|
|
} on DioException catch (e) {
|
|
emit(BannersFail());
|
|
if (kDebugMode) {
|
|
print("Dio Error is: $e");
|
|
}
|
|
}
|
|
}
|
|
}
|