Giter VIP home page Giter VIP logo

Comments (3)

adityasethipsi avatar adityasethipsi commented on August 18, 2024

Please need support on this ASAP.

from stream-chat-flutter.

deven98 avatar deven98 commented on August 18, 2024

Hey @adityasethipsi 👋

This usually occurs in a situation when the StreamChat widget is inaccessible by the Stream widget using the theme. Try checking through how you're using any navigation.

As for the sample you provided, the same works for me on 7.2.1 - here is a complete sample using your code if you want to run this yourself:

(Paste this in your main.dart and hit run)

// ignore_for_file: public_member_api_docs

import 'dart:async';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  /// Create a new instance of [StreamChatClient] passing the apikey obtained
  /// from your project dashboard.
  final client = StreamChatClient(
    's2dxdhpxd94g',
    logLevel: Level.OFF,
  );

  /// Set the current user and connect the websocket. In a production
  /// scenario, this should be done using a backend to generate a user token
  /// using our server SDK.
  ///
  /// Please see the following for more information:
  /// https://getstream.io/chat/docs/ios_user_setup_and_tokens/
  await client.connectUser(
    User(id: 'super-band-9'),
    '''eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A''',
  );

  runApp(
    StreamChatPage(
      client: client,
    ),
  );
}

class StreamChatPage extends StatefulWidget {
  final StreamChatClient client;
  const StreamChatPage({
    super.key,
    required this.client,
  });

  @override
  StreamChatPageState createState() => StreamChatPageState();
}

class StreamChatPageState extends State<StreamChatPage> {
  late Channel channel;

  StreamChatPageState();

  @override
  void dispose() {
    channel.stopWatching();
    channel.dispose();
    super.dispose();
  }

  @override
  void initState() {
    super.initState();
    channel = widget.client.channel(
      'messaging',
      id: 'flutterDevs',
    );
  }

  @override
  Widget build(BuildContext context) {
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      channel.watch();
    });
    final theme = ThemeData(
      primarySwatch: Colors.green,
    );
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData.light(),
      darkTheme: ThemeData.dark(),
      // themeMode: ThemeMode.dark,
      supportedLocales: const [
        Locale('en'),
        Locale('hi'),
        Locale('fr'),
        Locale('it'),
        Locale('es'),
      ],
      builder: (context, a) => StreamChat(
        client: widget.client,
        child: a ?? Container(),
      ),
      home: StreamChannel(
        channel: channel,
        child: ChannelPage(channel),
      ),
    );
  }
}

class ChannelPage extends StatefulWidget {
  final Channel channel;

  const ChannelPage(this.channel);

  @override
  _ChannelPageState createState() => _ChannelPageState();
}

class _ChannelPageState extends State<ChannelPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Expanded(
            child: StreamMessageListView(
              messageBuilder: (p0, p1, p2, defaultMessageWidget) {
                return defaultMessageWidget.copyWith(
                  showDeleteMessage: true,
                  showEditMessage: true,
                  showReactionPicker: true,
                  showReactions: true,
                  showReplyMessage: true,
                );
                StreamMessageWidget;
              },
            ),
          ),
          const StreamMessageInput(
            allowedAttachmentPickerTypes: [AttachmentPickerType.files],
          ),
        ],
      ),
    );
  }
}



const riveStreamReactionAnimations = [
  RiveStreamReaction(
    type: 'love',
    artboard: 'love',
    artboardHighlighted: 'love_highlight',
  ),
  RiveStreamReaction(
    type: 'like',
    artboard: 'like',
    artboardHighlighted: 'like_highlight',
  ),
  RiveStreamReaction(
    type: 'sad',
    artboard: 'sad',
    artboardHighlighted: 'sad_highlight',
  ),
  RiveStreamReaction(
    type: 'haha',
    artboard: 'haha',
    artboardHighlighted: 'haha_highlight',
  ),
  RiveStreamReaction(
    type: 'wow',
    artboard: 'wow',
    artboardHighlighted: 'wow_highlight',
  ),
];

@immutable
class RiveStreamReaction {
  final String type;
  final String artboard;
  final String artboardHighlighted;

  const RiveStreamReaction({
    required this.type,
    required this.artboard,
    required this.artboardHighlighted,
  });
}

class ReactionPicker extends StatelessWidget {
  final Message message;
  final void Function(String) onReactionTap;

  const ReactionPicker({
    Key? key,
    required this.message,
    required this.onReactionTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Wrap(
      children: [
        IconButton(
          icon: const Text('😀'),
          onPressed: () => onReactionTap('smile'),
        ),
        IconButton(
          icon: const Text('😢'),
          onPressed: () => onReactionTap('sad'),
        ),
        IconButton(
          icon: const Text('👍'),
          onPressed: () => onReactionTap('thumbs_up'),
        ),
        IconButton(
          icon: const Text('❤️'),
          onPressed: () => onReactionTap('heart'),
        ),
      ],
    );
  }
}

Let me know if there's something I'm missing here. If you're still getting this error after trying the sample above, please add the code you're using to connect and get until the messaging page. Thanks.

from stream-chat-flutter.

deven98 avatar deven98 commented on August 18, 2024

Closing this for now as I cannot replicate the bug with your code but feel free to reopen this if needed. Thanks!

from stream-chat-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.