import 'package:flutter/material.dart';
import 'package:talkjs_flutter/talkjs_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final session = Session(appId: 'tPKdyezd');
final me = session.getUser(
id: '123456',
name: 'Alice',
email: ['alice@example.com'],
photoUrl: 'https://talkjs.com/images/avatar-1.jpg',
welcomeMessage: 'Hey there! How are you? :-)',
);
session.me = me;
final other = session.getUser(
id: '654321',
name: 'Sebastian',
email: ['Sebastian@example.com'],
photoUrl: 'https://talkjs.com/images/avatar-5.jpg',
welcomeMessage: 'Hey, how can I help?',
);
final conversation = session.getConversation(
id: Talk.oneOnOneId(me.id, other.id),
participants: {Participant(me), Participant(other)},
);
return MaterialApp(
title: 'TalkJS Demo',
home: Scaffold(
appBar: AppBar(
title: const Text('TalkJS Demo'),
),
body: ChatBox(
session: session,
conversation: conversation,
),
),
);
}
}
<script>
import 'package:flutter/material.dart';
import 'package:talkjs_flutter/talkjs_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final session = Session(appId: 'YOUR_APP_ID');
final me = session.getUser(
id: '123456',
name: 'Alice',
email: ['alice@example.com'],
photoUrl: 'https://talkjs.com/images/avatar-1.jpg'
);
session.me = me;
final other = session.getUser(
id: '654321',
name: 'Sebastian',
email: ['Sebastian@example.com'],
photoUrl: 'https://talkjs.com/images/avatar-5.jpg'
);
final conversation = session.getConversation(
id: Talk.oneOnOneId(me.id, other.id),
participants: {Participant(me), Participant(other)},
);
return MaterialApp(
title: 'TalkJS Demo',
home: Scaffold(
appBar: AppBar(
title: const Text('TalkJS Demo'),
),
body: ChatBox(
session: session,
conversation: conversation,
),
),
);
}
}
</script>
Because implementing TalkJS was as fast and easy as it was, we were able to greenlight and move this project along very quickly. Had we not chosen this path, the feature would have either been delayed, or shelved due to the resources needed to implement it.