doc: Added some docs for core code

This commit is contained in:
Deven Joshi
2021-01-26 18:44:02 +05:30
parent b26fcd171d
commit ec858e4973
4 changed files with 73 additions and 21 deletions
@@ -11,14 +11,15 @@ import 'stream_chat_core.dart';
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_list_view.png)
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_list_view_paint.png)
///
/// It shows the list of current channels.
/// [ChannelListCore] is a simplified class that allows fetching a list of channels while exposing UI builders.
/// A [ChannelListController] is used to reload and paginate data.
///
/// ```dart
/// class ChannelListPage extends StatelessWidget {
/// @override
/// Widget build(BuildContext context) {
/// return Scaffold(
/// body: ChannelListView(
/// body: ChannelListCore(
/// filter: {
/// 'members': {
/// '\$in': [StreamChat.of(context).user.id],
@@ -28,7 +29,24 @@ import 'stream_chat_core.dart';
/// pagination: PaginationParams(
/// limit: 20,
/// ),
/// channelWidget: ChannelPage(),
/// errorBuilder: (err) {
/// return Center(
/// child: Text('An error has occured'),
/// );
/// },
/// emptyBuilder: (context) {
/// return Center(
/// child: Text('Nothing here...'),
/// );
/// },
/// emptyBuilder: (context) {
/// return Center(
/// child: CircularProgressIndicator(),
/// );
/// },
/// listBuilder: (context, list) {
/// return ChannelPage(list);
/// }
/// ),
/// );
/// }
@@ -37,10 +55,6 @@ import 'stream_chat_core.dart';
///
///
/// Make sure to have a [StreamChatCore] ancestor in order to provide the information about the channels.
/// The widget uses a [ListView.custom] to render the list of channels.
///
/// The widget components render the ui based on the first ancestor of type [StreamChatTheme].
/// Modify it to change the widget appearance.
class ChannelListCore extends StatefulWidget {
/// Instantiate a new ChannelListView
ChannelListCore({
@@ -56,13 +70,17 @@ class ChannelListCore extends StatefulWidget {
this.channelListController,
}) : super(key: key);
/// A [ChannelListController] allows reloading and pagination.
/// Use [ChannelListController.loadData] and [ChannelListController.paginateData] respectively for reloading and pagination.
final ChannelListController channelListController;
/// The builder that will be used in case of error
final Widget Function(Error error) errorBuilder;
/// The builder that will be used in case of loading
final WidgetBuilder loadingBuilder;
/// The builder which is used when list of channels loads
final Function(BuildContext, List<Channel>) listBuilder;
/// The builder used when the channel list is empty.
@@ -8,7 +8,8 @@ import 'stream_channel.dart';
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/message_listview.png)
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/message_listview_paint.png)
///
/// It shows the list of messages of the current channel.
/// [MessageListCore] is a simplified class that allows fetching a list of messages while exposing UI builders.
/// A [MessageListController] is used to paginate data.
///
/// ```dart
/// class ChannelPage extends StatelessWidget {
@@ -19,19 +20,25 @@ import 'stream_channel.dart';
/// @override
/// Widget build(BuildContext context) {
/// return Scaffold(
/// appBar: ChannelHeader(),
/// body: Column(
/// children: <Widget>[
/// Expanded(
/// child: MessageListView(
/// threadBuilder: (_, parentMessage) {
/// return ThreadPage(
/// parent: parentMessage,
/// );
/// },
/// child: MessageListCore(
/// emptyBuilder: (context) {
/// return Center(
/// child: Text('Nothing here...'),
/// );
/// },
/// emptyBuilder: (context) {
/// return Center(
/// child: CircularProgressIndicator(),
/// );
/// },
/// messageListBuilder: (context, list) {
/// return MessagesPage(list);
/// }
/// ),
/// ),
/// MessageInput(),
/// ],
/// ),
/// );
@@ -57,6 +64,8 @@ class MessageListCore extends StatefulWidget {
this.messageListController,
}) : super(key: key);
/// A [MessageListController] allows pagination.
/// Use [ChannelListController.paginateData] pagination.
final MessageListController messageListController;
final Widget Function(BuildContext, List<Message>) messageListBuilder;
@@ -5,14 +5,15 @@ import 'package:stream_chat/stream_chat.dart';
import 'message_search_bloc.dart';
///
/// It shows the list of searched messages.
/// [MessageSearchListCore] is a simplified class that allows searching for messages across channels while exposing UI builders.
/// A [MessageSearchListController] is used to load and paginate data.
///
/// ```dart
/// class MessageSearchPage extends StatelessWidget {
/// @override
/// Widget build(BuildContext context) {
/// return Scaffold(
/// body: MessageSearchListView(
/// body: MessageSearchListCore(
/// messageQuery: _channelQuery,
/// filters: {
/// 'members': {
@@ -48,6 +49,8 @@ class MessageSearchListCore extends StatefulWidget {
this.messageSearchListController,
}) : super(key: key);
/// A [MessageSearchListController] allows reloading and pagination.
/// Use [MessageSearchListController.loadData] and [MessageSearchListController.paginateData] respectively for reloading and pagination.
final MessageSearchListController messageSearchListController;
/// Message String to search on
@@ -75,6 +78,7 @@ class MessageSearchListCore extends StatefulWidget {
/// You can also filter other built-in channel fields.
final Map<String, dynamic> messageFilters;
/// The builder that is used when the search messages are fetched
final Widget Function(List<GetMessageResponse>) childBuilder;
/// The builder used when the channel list is empty.
@@ -83,6 +87,7 @@ class MessageSearchListCore extends StatefulWidget {
/// The builder that will be used in case of error
final Widget Function(Error error) errorBuilder;
/// The builder that will be used in case of loading
final WidgetBuilder loadingBuilder;
@override
@@ -5,14 +5,15 @@ import 'package:stream_chat/stream_chat.dart';
import 'package:stream_chat_flutter_core/src/users_bloc.dart';
///
/// It shows the list of current users.
/// [UserListCore] is a simplified class that allows fetching users while exposing UI builders.
/// A [UserListController] is used to load and paginate data.
///
/// ```dart
/// class UsersListPage extends StatelessWidget {
/// @override
/// Widget build(BuildContext context) {
/// return Scaffold(
/// body: UsersListView(
/// body: UsersListCore(
/// filter: {
/// 'members': {
/// '\$in': [StreamChat.of(context).user.id],
@@ -22,7 +23,24 @@ import 'package:stream_chat_flutter_core/src/users_bloc.dart';
/// pagination: PaginationParams(
/// limit: 20,
/// ),
/// channelWidget: ChannelPage(),
/// errorBuilder: (err) {
/// return Center(
/// child: Text('An error has occured'),
/// );
/// },
/// emptyBuilder: (context) {
/// return Center(
/// child: Text('Nothing here...'),
/// );
/// },
/// emptyBuilder: (context) {
/// return Center(
/// child: CircularProgressIndicator(),
/// );
/// },
/// listBuilder: (context, list) {
/// return UsersPage(list);
/// }
/// ),
/// );
/// }
@@ -51,6 +69,8 @@ class UserListCore extends StatefulWidget {
this.userListController,
}) : super(key: key);
/// A [UserListController] allows reloading and pagination.
/// Use [UserListController.loadData] and [UserListController.paginateData] respectively for reloading and pagination.
final UserListController userListController;
/// The builder that will be used in case of error