Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:likeminds_chat_flutter_core/likeminds_chat_flutter_core.dart';

class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('LM Sample Chat'),
),
body: Center(
child: ElevatedButton(
onPressed: () async {
// TODO: Replace with YOUR_API_KEY, YOUR_UUID, and YOUR_USER_NAME
// initiate user session with apiKey, uuid and userName
// this is required to show the chat. MAKE SURE TO ALWAYS USE THESE CREDENTIAL FOR OUTPUT.
LMResponse<void> response =
await LMChatCore.instance.showChatWithApiKey(
apiKey: "83c8f0ed-a9e2-4634-9a2e-d9c7a1e39ff8",
uuid: "abc",
userName: "abc",
);
if (response.success) {
// create route with LMChatSocialScreen
MaterialPageRoute route = MaterialPageRoute(
builder: (context) => const LMChatHomeScreen(),
);
// navigate to LMChatSocialScreen
Navigator.pushReplacement(context, route);
} else {
debugPrint("Error opening chat: ${response.errorMessage}");
}
},
child: const Text('Open Chat'),
),
),
);
}
}