1<script>
2
3 import 'package:flutter/material.dart';
4 import 'package:talkjs_flutter/talkjs_flutter.dart';
5
6 void main() {
7 runApp(const MyApp());
8 }
9
10 class MyApp extends StatelessWidget {
11 const MyApp({Key? key}) : super(key: key);
12
13
14 @override
15 Widget build(BuildContext context) {
16 final session = Session(appId: 'YOUR_APP_ID');
17
18 final me = session.getUser(
19 id: '123456',
20 name: 'Alice',
21 email: ['alice@example.com'],
22 photoUrl: 'https://talkjs.com/images/avatar-1.jpg'
23 );
24
25 session.me = me;
26
27 final other = session.getUser(
28 id: '654321',
29 name: 'Sebastian',
30 email: ['Sebastian@example.com'],
31 photoUrl: 'https://talkjs.com/images/avatar-5.jpg'
32 );
33
34 final conversation = session.getConversation(
35 id: Talk.oneOnOneId(me.id, other.id),
36 participants: {Participant(me), Participant(other)},
37 );
38
39 return MaterialApp(
40 title: 'TalkJS Demo',
41 home: Scaffold(
42 appBar: AppBar(
43 title: const Text('TalkJS Demo'),
44 ),
45 body: ChatBox(
46 session: session,
47 conversation: conversation,
48 ),
49 ),
50 );
51 }
52 }
53</script>