talkjs/talkjs-examples

Chatbox screen not loading in flutter

chima94 opened this issue · 1 comments

The chatbox screen loads sometimes and other time it does not. This happens when I want to create a new conversation. I have followed the doc and its code step by step and still getting same error.

The code i am working with:

class ChatBoxPage extends StatefulWidget {
   const ChatBoxPage({Key? key}) : super(key: key);

  @override
   State<ChatBoxPage> createState() => _ChatBoxPageState();
}

 class _ChatBoxPageState extends State<ChatBoxPage> {
    bool isLoading = false;

    @override
    Widget build(BuildContext context) {

    final session = Session(appId: 'MyAPPID'); //my app id

    final me = session.getUser(
        id: '99876',
        name: 'collins',
        email: ['collins@example.com'],
        photoUrl: 'https://talkjs.com/images/avatar-1.jpg',
        welcomeMessage: 'Hey there! How are you? :-)',
        role: 'default',
    );

    session.me = me;

    final other = session.getUser(
      id: '09087',
      name: 'Ify',
      email: ['Ify@example.com'],
      photoUrl: 'https://talkjs.com/images/avatar-5.jpg',
      welcomeMessage: 'Hey, how can I help?',
      role: 'default',
    );

    final conversation = session.getConversation(
      id: Talk.oneOnOneId(me.id, other.id),
      participants: {Participant(me), Participant(other)},
    );
    return Scaffold(
      appBar: AppBar(
        title: const Text('TalkJS Demo'),
      ),
      body: ChatBox(
        session: session,
        conversation: conversation,
        asGuest: true,
      ),
    );
  }
}

Please i will really appreciate a quick response as my appplication depends on the chat functionality

Hi, you mention that the chat sometimes loads and sometimes doesn't. Do you see any errors in the console when it doesn't work?

I have asked my colleague that's more familiar with the flutter SDK to take a look at this. In the mean time, I'd encourage you to contact us via live chat. You'll still end up chatting with a developer that way, but we can share sensitive details like App / User / Conversation IDs without leaking them. You can contact us by clicking the chat button in the bottom right of talkjs.com