This commit is contained in:
Deven Joshi
2021-05-05 16:38:05 +05:30
parent 645d21503a
commit d55b937364
2 changed files with 33 additions and 21 deletions
@@ -3,10 +3,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// Used to show the sending status of the message
class SendingIndicator extends StatelessWidget {
final Message message;
final bool isMessageRead;
final double? size;
/// Constructor for creating a [SendingIndicator] widget
const SendingIndicator({
Key? key,
required this.message,
@@ -14,6 +11,15 @@ class SendingIndicator extends StatelessWidget {
this.size = 12,
}) : super(key: key);
/// Message for sending indicator
final Message message;
/// Flag if message is read
final bool isMessageRead;
/// Size for message
final double? size;
@override
Widget build(BuildContext context) {
if (isMessageRead) {
@@ -35,6 +41,6 @@ class SendingIndicator extends StatelessWidget {
size: size,
);
}
return SizedBox();
return const SizedBox();
}
}
@@ -31,18 +31,7 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
///
/// Use [StreamChat.of] to get the current [StreamChatState] instance.
class StreamChat extends StatefulWidget {
final StreamChatClient client;
final Widget? child;
final StreamChatThemeData? streamChatThemeData;
/// The amount of time that will pass before disconnecting the client in the background
final Duration backgroundKeepAlive;
/// Handler called whenever the [client] receives a new [Event] while the app
/// is in background. Can be used to display various notifications depending
/// upon the [Event.type]
final EventHandler? onBackgroundEventReceived;
/// Constructor for creating a [StreamChat] widget
const StreamChat({
Key? key,
required this.client,
@@ -50,9 +39,25 @@ class StreamChat extends StatefulWidget {
this.streamChatThemeData,
this.onBackgroundEventReceived,
this.backgroundKeepAlive = const Duration(minutes: 1),
}) : super(
key: key,
);
}) : super(key: key);
/// Client to do chat ops with
final StreamChatClient client;
/// Child which inherits details
final Widget? child;
/// Theme to pass on
final StreamChatThemeData? streamChatThemeData;
/// The amount of time that will pass before disconnecting the client
/// in the background
final Duration backgroundKeepAlive;
/// Handler called whenever the [client] receives a new [Event] while the app
/// is in background. Can be used to display various notifications depending
/// upon the [Event.type]
final EventHandler? onBackgroundEventReceived;
@override
StreamChatState createState() => StreamChatState();
@@ -74,6 +79,7 @@ class StreamChat extends StatefulWidget {
/// The current state of the StreamChat widget
class StreamChatState extends State<StreamChat> {
/// Gets client from widget
StreamChatClient get client => widget.client;
@override
@@ -96,7 +102,7 @@ class StreamChatState extends State<StreamChat> {
client: client,
onBackgroundEventReceived: widget.onBackgroundEventReceived,
backgroundKeepAlive: widget.backgroundKeepAlive,
child: widget.child ?? Offstage(),
child: widget.child ?? const Offstage(),
),
);
},