// ignore_for_file: public_member_api_docs import 'dart:async'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; class DebugChannelPage extends StatefulWidget { const DebugChannelPage({super.key}); @override State createState() { return _DebugChannelPageState(); } } class _DebugChannelPageState extends State { late final Channel _channel = StreamChannel.of(context).channel; StreamSubscription? _channelSubscription; StreamSubscription? _ownUserSubscription; ChannelState? _channelState; OwnUser? _ownUser; @override void initState() { super.initState(); _channelSubscription = _channel.state!.channelStateStream.listen((state) { setState(() => _channelState = state); }); _ownUserSubscription = _channel.client.state.currentUserStream.listen((ownUser) { setState(() => _ownUser = ownUser); }); } @override void dispose() { super.dispose(); _channelSubscription?.cancel(); _ownUserSubscription?.cancel(); } @override Widget build(BuildContext context) { final members = _channelState?.members ?? _channel.state?.members ?? const []; final mutes = _ownUser?.mutes ?? _channel.client.state.currentUser?.mutes ?? const []; //SingleChildScrollView return Scaffold( appBar: AppBar( title: Text(_channel.name ?? _channel.cid ?? '?'), ), body: SingleChildScrollView( padding: const EdgeInsets.only(bottom: 16), child: Column( mainAxisSize: MainAxisSize.min, children: [ DebugMe(client: _channel.client), ], ), ), ); } } class DebugMe extends StatelessWidget { const DebugMe({ super.key, required this.client, }); final StreamChatClient client; @override Widget build(BuildContext context) { return Container( alignment: Alignment.centerLeft, padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 12), child: Row( children: [ const Text( 'Me: ', style: TextStyle( color: Colors.red, fontSize: 16, fontWeight: FontWeight.bold, ), ), Text( client.state.currentUser?.id ?? '?', style: const TextStyle( fontSize: 16, fontWeight: FontWeight.bold, ), ), ], ), ); } }