Skip to content

Instantly share code, notes, and snippets.

View FlutterWiz's full-sized avatar
🎯
Discipline

FlutterWiz FlutterWiz

🎯
Discipline
View GitHub Profile
Future<void> sendCapturedPhotoToSelectedUsers({
required String pathOfTheTakenPhoto,
required int sizeOfTheTakenPhoto,
}) async {
if (state.isInProgress) {
return;
}
emit(state.copyWith(isInProgress: true));
@override
Future<void> close() async {
await _currentUserChannelsSubscription?.cancel();
super.close();
}
void reset() {
emit(
state.copyWith(
isInProgress: false,
@override
Future<void> close() async {
await _currentUserChannelsSubscription?.cancel();
super.close();
}
void reset() {
emit(
state.copyWith(
isInProgress: false,
part of 'chat_management_cubit.dart';
@freezed
class ChatManagementState with _$ChatManagementState {
const factory ChatManagementState({
required bool isInProgress,
required bool isChannelNameValid,
required bool isChannelCreated,
required bool isCapturedPhotoSent,
required String channelName,
part of 'chat_management_cubit.dart';
@freezed
class ChatManagementState with _$ChatManagementState {
const factory ChatManagementState({
required bool isInProgress,
required bool isChannelNameValid,
required bool isChannelCreated,
required bool isCapturedPhotoSent,
required String channelName,
part 'chat_setup_state.dart';
part 'chat_setup_cubit.freezed.dart';
@lazySingleton
class ChatSetupCubit extends HydratedCubit<ChatSetupState> {
late StreamSubscription<ChatUserModel>? _chatUserSubscription;
late final IChatService _chatService;
ChatSetupCubit() : super(ChatSetupState.empty()) {
part of 'chat_setup_cubit.dart';
@freezed
class ChatSetupState with _$ChatSetupState {
const factory ChatSetupState({
required ChatUserModel chatUser,
required ConnectionStatus webSocketConnectionStatus,
required bool isUserCheckedFromChatService,
}) = _ChatSetupState;
Future<void> signOut() async {
await _authService.signOut();
await _chatService.disconnectUser();
}
Future<void> _listenAuthStateChangesStream(AuthUserModel authUser) async {
emit(
state.copyWith(
isInProgress: true,
authUser: authUser,
@override
Future<void> sendPhotoAsMessageToTheSelectedUser({
required String channelId,
required int sizeOfTheTakenPhoto,
required String pathOfTheTakenPhoto,
}) async {
final randomMessageId = const Uuid().v1();
final signedInUserOption = await _firebaseAuth.getSignedInUser();
final signedInUser = signedInUserOption.fold(
@override
Future<void> createNewChannel({
required List<String> listOfMemberIDs,
required String channelName,
required String channelImageUrl,
}) async {
final randomId = const Uuid().v1();
await streamChatClient.createChannel(
"messaging",