Files
prosappweb/lib/providers/chat_provider.dart
T
Lizandro GuarnizoandClaude Sonnet 4.6 15175c1b91 replace: swap prosappweb content for prosapp_web_app (more complete version)
prosapp_web_app has chat, dashboard, calendar, support, 13 providers and
Fluro URL routing. Keep Dockerfile + nginx.conf from previous prosappweb.
Upgrade google_fonts 6.2.1 → 8.1.0 (Dart 3.12 compat fix).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 15:26:32 -05:00

35 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:prosapp_web_app/models/chat_entity.dart';
import 'package:prosapp_web_app/models/message_entity.dart';
import 'package:prosapp_web_app/repositories/firebase_chat_repository.dart';
class ChatProvider with ChangeNotifier {
final FirebaseChatRepository _firebaseChatRepository =
FirebaseChatRepository();
ChatEntity? _currentChat;
ChatEntity? get currentChat => _currentChat;
Stream<ChatEntity?> getChat(String chatId) {
return _firebaseChatRepository.getChatById(chatId).map((chat) {
_currentChat = chat;
notifyListeners();
return chat;
});
}
Future<ChatEntity> createChat(
String chatId, String userId, String professionalId) async {
final chat = await _firebaseChatRepository.createNewChat(
chatId, userId, professionalId);
_currentChat = chat;
notifyListeners();
return chat;
}
Future<void> sendMessage(String chatId, MessageEntity message) async {
await _firebaseChatRepository.sendMessage(chatId, message);
notifyListeners();
}
}