GetStream / flutter-samples

A collection of sample apps that use Stream
https://getstream.io/chat/docs/flutter-dart/
MIT License
301 stars 126 forks source link

The message screen gets an error without the Martial app. #82

Closed ChiragGajjar closed 2 years ago

ChiragGajjar commented 2 years ago

======== Exception caught by widgets library ======================================================= The following assertion was thrown building StreamChannelHeader(dirty, dependencies: [_LocalizationsScope-[GlobalKey#275e6], _InheritedTheme]): You must have a StreamChatTheme widget at the top of your widget tree 'package:stream_chat_flutter/src/stream_chat_theme.dart': Failed assertion: line 25 pos 7: 'streamChatTheme != null'

` return Scaffold(
      body:RefreshIndicator(
        onRefresh: _controller.refresh,
        child: StreamChannelListView(
          controller: _controller,
            onChannelTap: (channel) => Navigator.of(context, rootNavigator: true).push(
              MaterialPageRoute(
                builder: (_) => StreamChannel(
                  channel: channel,
                  child: StreamChannelScreen(channel: channel),
                ),
              ),
            ),
        ),
      ),
    );`
imtoori commented 2 years ago

Hi is this in the sample app? can you give me more information?

ChiragGajjar commented 2 years ago

Yes, but I am not using MaterialApp, because I have my own custom navigation.

imtoori commented 2 years ago

yeah but you still need a StreamChat widget on top of your widget tree? did you add that?

ChiragGajjar commented 2 years ago

Yes, Check my code here

return StreamChat( client: client, streamChatThemeData: StreamChatThemeData.fromTheme(theme), child: ChannelListPage(client: client,), );

imtoori commented 2 years ago

The StreamChat widget should be on top of the navigator because it needs to be retrievable by other widgets in every route Can you try moving it above the navigator?

ChiragGajjar commented 2 years ago

Like this? This is working fine, it shows a nested view but I don't use this MaterialApp because i have my custom header.

return Scaffold( body: MaterialApp( builder: (context, child) => StreamChat( client: client, streamChatThemeData: StreamChatThemeData.fromTheme(theme), child: child, ), home: ChannelListPage(client: client,), ), );

imtoori commented 2 years ago

yes, but you told me you're not using the MaterialApp widget, right?

ChiragGajjar commented 2 years ago

Correct

imtoori commented 2 years ago

you need to put the StreamChat widget on top of your custom navigator

ChiragGajjar commented 2 years ago

WhatsApp Image 2022-07-25 at 5 56 47 PM This looks like this. so i want to navigate outside the navigator, i don't need the bottom bar and top bar.

imtoori commented 2 years ago

ok I'm sorry the snippet is wrong, I just noticed there's a scaffold as top widget.

That said

Yes, but I am not using MaterialApp, because I have my own custom navigation.

You should put the StreamChat widget above the navigator widget you're using

ChiragGajjar commented 2 years ago

I have tried this but, but user listing screen showing correctly but when i tap on the chat details screen its showing error like this

The following assertion was thrown building _BodyBuilder: You must have a StreamChatTheme widget at the top of your widget tree 'package:stream_chat_flutter/src/stream_chat_theme.dart': Failed assertion: line 25 pos 7: 'streamChatTheme != null'

imtoori commented 2 years ago

mmm can you show me where do you put the StreamChat widget? Sorry for the many questions, but I need more info

ChiragGajjar commented 2 years ago

@imtoori thanks a lot, I have not added StreamChat in chat details at the top. now it's working fine. Thanks.

imtoori commented 2 years ago

sounds good even if I would still put it above the navigator widget