UserListCore class Null safety

UserListCore is a simplified class that allows fetching users while exposing UI builders. A UserListController is used to load and paginate data.

class UsersListPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: UsersListCore(
        filter: {
          'members': {
            '\$in': [StreamChat.of(context).user.id],
          }
        },
        sort: [SortOption('last_message_at')],
        pagination: PaginationParams(
          limit: 20,
        ),
        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);
        }
      ),
    );
  }
}

UsersBloc must be the ancestor of this widget. This is necessary since UserListCore depends on functionality contained within UsersBloc.

The parameters listBuilder, loadingBuilder, emptyBuilder and errorBuilder must all be supplied and not null.

Inheritance

Constructors

UserListCore({required ErrorBuilder errorBuilder, required WidgetBuilder emptyBuilder, required WidgetBuilder loadingBuilder, required Widget listBuilder(BuildContext context, List<ListItem> users), Key? key, Filter filter = const Filter.empty(), List<SortOption>? sort, bool? presence, bool groupAlphabetically = false, UserListController? userListController, int limit = 30})
Instantiate a new UserListCore
const

Properties

emptyBuilder WidgetBuilder
The builder used when the channel list is empty.
final
errorBuilder ErrorBuilder
The builder that will be used in case of error
final
filter Filter
The query filters to use. You can query on any of the custom fields you've defined on the Channel. You can also filter other built-in channel fields.
final
groupAlphabetically bool
Set it to true to group users by their first character [...]
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
limit int
The amount of users requested per API call.
final
listBuilder Widget Function(BuildContext context, List<ListItem> users)
The builder that will be used to build the list
final
loadingBuilder WidgetBuilder
The builder that will be used for loading
final
presence bool?
If true you’ll receive user presence updates via the websocket events
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
sort List<SortOption>?
The sorting used for the channels matching the filters. Sorting is based on field and direction, multiple sorting options can be provided. You can sort based on last_updated, last_message_at, updated_at, created_at or member_count. Direction can be ascending or descending.
final
userListController UserListController?
A UserListController allows reloading and pagination. Use UserListController.loadData and UserListController.paginateData respectively for reloading and pagination.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
createState() → UserListCoreState
Creates the mutable state for this widget at a given location in the tree. [...]
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object. [...]
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
@nonVirtual, inherited