feat(chat): API method info success

This commit is contained in:
2024-05-07 11:59:37 +03:00
parent d9956ed549
commit d537a05fac
5 changed files with 90 additions and 97 deletions

View File

@@ -27,9 +27,10 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
AppRoutes.authScreen,
);
}
final String? id = state.chatModelObj?.chatID;
final String? chatID = state.chatModelObj?.chatID;
print(chatID);
final response = await http.get(
Uri.parse(dotenv.env['SERVER_ROOT']! + '/chat/show/$id'),
Uri.parse(dotenv.env['SERVER_ROOT']! + '/chat/show/$chatID'),
headers: {
'Authorization': 'Bearer $token',
},

View File

@@ -14,15 +14,3 @@ class ChatInitialEvent extends ChatEvent {
@override
List<Object?> get props => [];
}
///event for dropdown selection
class ChangeDropDownEvent extends ChatEvent {
ChangeDropDownEvent({required this.value});
SelectionPopupModel value;
@override
List<Object?> get props => [
value,
];
}

View File

@@ -12,11 +12,12 @@ import 'package:eatvio_app/widgets/custom_text_form_field.dart';
class ChatScreen extends StatelessWidget {
const ChatScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final String chatID = ModalRoute.of(context)!.settings.arguments as String;
final chatID = ModalRoute.of(context)!.settings.arguments;
print(chatID.toString());
return BlocProvider<ChatBloc>(
create: (context) =>
ChatBloc(ChatState(chatModelObj: ChatModel(chatID: chatID)))
..add(ChatInitialEvent()),
create: (context) => ChatBloc(
ChatState(chatModelObj: ChatModel(chatID: chatID.toString())))
..add(ChatInitialEvent()),
child: ChatScreen());
}

View File

@@ -4,9 +4,11 @@ import 'package:equatable/equatable.dart';
/// This class defines the variables used in the [chat_screen],
/// and is typically used to hold data that is passed between different parts of the application.
class ChatModel extends Equatable {
String? chatID;
ChatModel({String? chatID});
final String chatID;
ChatModel({required String chatID}) : chatID = chatID;
ChatModel copyWith(String chatID) {
return ChatModel(chatID: chatID);