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
@@ -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(),
),
);
},