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/plans_model.dart'; import 'package:hoshan/data/repository/paymant_repository.dart'; part 'plans_event.dart'; part 'plans_state.dart'; class PlansBloc extends Bloc { PlansBloc() : super(PlansInitial()) { on((event, emit) async { if (event is GetAllPlans) { emit(PlansLoading()); try { final plans = await PaymantRepository.getPaymantPlans(); emit(PlansSuccess(plans: plans)); } on DioException catch (e) { emit(PlansFail()); if (kDebugMode) { print('Dio Error is: $e'); } } } }); } }