Info:
This is documentation for Stream Chat Flutter SDK v3, which is no longer actively maintained. For up-to-date documentation, see the latest version (v10).

UserListCore

A Widget For Building A List Of Users

Background

The UI SDK of Stream Chat supplies a UserListView class that builds a list of channels fetching according to the filters and sort order given. However, in some cases, implementing novel UI is necessary that cannot be done using the customization approaches given in the widget.

To do this, we extracted the logic required for fetching channels into a 'Core' widget - a widget that fetches channels in the expected way via the usual parameters but does not supply any UI and instead exposes builders to build the UI in situations such as loading, empty data, errors, and on data received.

Basic Example

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(
        sort: [SortOption('last_active')],
        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.

Add Chat to my app: getstream.io/SKILL.md

The fastest way to build with Stream. Start a new project or improve an existing one. Full CLI and documentation integration out of the box.


Ask your agent:

/stream Build me a Social App with Feeds and Moderation.
/stream Any livestream calls running?
/stream Chat Flutter v3: <Your Question>