elCaribe app - customization and branding
This commit is contained in:
36
news-app/lib/cubits/NewsComment/flagCommentCubit.dart
Normal file
36
news-app/lib/cubits/NewsComment/flagCommentCubit.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:news/data/repositories/NewsComment/FlagComment/flagCommRepository.dart';
|
||||
|
||||
abstract class SetFlagState {}
|
||||
|
||||
class SetFlagInitial extends SetFlagState {}
|
||||
|
||||
class SetFlagFetchInProgress extends SetFlagState {}
|
||||
|
||||
class SetFlagFetchSuccess extends SetFlagState {
|
||||
String message;
|
||||
|
||||
SetFlagFetchSuccess({required this.message});
|
||||
}
|
||||
|
||||
class SetFlagFetchFailure extends SetFlagState {
|
||||
final String errorMessage;
|
||||
|
||||
SetFlagFetchFailure(this.errorMessage);
|
||||
}
|
||||
|
||||
class SetFlagCubit extends Cubit<SetFlagState> {
|
||||
final SetFlagRepository _setFlagRepository;
|
||||
|
||||
SetFlagCubit(this._setFlagRepository) : super(SetFlagInitial());
|
||||
|
||||
void setFlag({required String commId, required String newsId, required String message}) async {
|
||||
try {
|
||||
emit(SetFlagFetchInProgress());
|
||||
final result = await _setFlagRepository.setFlag(message: message, newsId: newsId, commId: commId);
|
||||
emit(SetFlagFetchSuccess(message: result['message']));
|
||||
} catch (e) {
|
||||
emit(SetFlagFetchFailure(e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user