StreamChatConfigurationData constructor

StreamChatConfigurationData({
  1. Widget loadingIndicator = const StreamLoadingIndicator(),
  2. Widget defaultUserImage(
    1. BuildContext,
    2. User
    )?,
  3. Widget placeholderUserImage(
    1. BuildContext,
    2. User
    )?,
  4. List<StreamReactionIcon>? reactionIcons,
  5. bool? enforceUniqueReactions,
})

Provides global, user-configurable, non-theme related configuration options to Flutter applications that use Stream Chat.

In order to set these configuration options, you must pass an instance of this class to the StreamChat widget, or wrap a subtree using the StreamChatConfiguration inherited widget.

If you need to access the configuration directly at a later point in your application, you can use the StreamChatConfiguration.of method to retrieve it.

If no StreamChatConfigurationData is provided, the StreamChatConfiguration.defaults factory constructor is used to provide a default configuration.

If you want to keep some of the default values, but not others, you can use the StreamChatConfigurationData.copyWith method to override the values in question.

Example 1:

class MyApp extends StatelessWidget {
  const MyApp({
    required this.client,
  });

  final StreamChatClient client;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Container(
        child: StreamChat(
          client: client,
          // No configuration provided, so the defaults are used.
          child: ChannelListPage(),
        ),
      ),
    );
  }
}

Example 2:

class MyApp extends StatelessWidget {
  const MyApp({
    required this.client,
  });

  final StreamChatClient client;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Container(
        child: StreamChat(
          client: client,
          config: StreamChatConfiguration.defaults().copyWith(
            // Override a specific default value here
          ),
          child: ChannelListPage(),
        ),
      ),
    );
  }
}

Implementation

factory StreamChatConfigurationData({
  Widget loadingIndicator = const StreamLoadingIndicator(),
  Widget Function(BuildContext, User)? defaultUserImage,
  Widget Function(BuildContext, User)? placeholderUserImage,
  List<StreamReactionIcon>? reactionIcons,
  bool? enforceUniqueReactions,
}) {
  return StreamChatConfigurationData._(
    loadingIndicator: loadingIndicator,
    defaultUserImage: defaultUserImage ?? _defaultUserImage,
    placeholderUserImage: placeholderUserImage,
    reactionIcons: reactionIcons ?? _defaultReactionIcons,
    enforceUniqueReactions: enforceUniqueReactions ?? true,
  );
}