rename Client to StreamChatClient
This commit is contained in:
+6
-2
@@ -33,8 +33,12 @@ scripts:
|
||||
flutter build macos
|
||||
|
||||
|
||||
test: >
|
||||
melos exec -c 1 --fail-fast --dir-exists=test --ignore="*example*" --ignore="*web*" -- \
|
||||
test:dart: >
|
||||
melos exec -c 1 --fail-fast --no-flutter --dir-exists=test --ignore="*example*" --ignore="*web*" -- \
|
||||
flutter pub run test
|
||||
|
||||
test:flutter: >
|
||||
melos exec -c 1 --fail-fast --flutter --dir-exists=test --ignore="*example*" --ignore="*web*" -- \
|
||||
flutter test
|
||||
|
||||
test:web: >
|
||||
|
||||
@@ -28,7 +28,7 @@ There is a detailed Flutter example project in the `example` folder. You can dir
|
||||
First you need to instantiate a chat client. The Chat client will manage API call, event handling and manage the websocket connection to Stream Chat servers. You should only create the client once and re-use it across your application.
|
||||
|
||||
```dart
|
||||
final client = Client("stream-chat-api-key");
|
||||
final client = StreamChatClient("stream-chat-api-key");
|
||||
```
|
||||
|
||||
### Logging
|
||||
@@ -40,7 +40,7 @@ By default the Chat Client will write all messages with level Warn or Error to s
|
||||
During development you might want to enable more logging information, you can change the default log level when constructing the client.
|
||||
|
||||
```dart
|
||||
final client = Client("stream-chat-api-key", logLevel: Level.INFO);
|
||||
final client = StreamChatClient("stream-chat-api-key", logLevel: Level.INFO);
|
||||
```
|
||||
|
||||
#### Custom Logger
|
||||
@@ -52,7 +52,7 @@ myLogHandlerFunction = (LogRecord record) {
|
||||
// do something with the record (ie. send it to Sentry or Fabric)
|
||||
}
|
||||
|
||||
final client = Client("stream-chat-api-key", logHandlerFunction: myLogHandlerFunction);
|
||||
final client = StreamChatClient("stream-chat-api-key", logHandlerFunction: myLogHandlerFunction);
|
||||
```
|
||||
|
||||
### Offline storage
|
||||
@@ -64,7 +64,7 @@ class CustomChatPersistentClient extends ChatPersistenceClient {
|
||||
...
|
||||
}
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
apiKey ?? kDefaultStreamApiKey,
|
||||
logLevel: Level.INFO,
|
||||
)..chatPersistenceClient = CustomChatPersistentClient();
|
||||
@@ -80,7 +80,7 @@ final chatPersistentClient = StreamChatPersistenceClient(
|
||||
connectionMode: ConnectionMode.background,
|
||||
);
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
apiKey ?? kDefaultStreamApiKey,
|
||||
logLevel: Level.INFO,
|
||||
)..chatPersistenceClient = chatPersistentClient;
|
||||
|
||||
@@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
/// Create a new instance of [Client] passing the apikey obtained from your
|
||||
/// Create a new instance of [StreamChatClient] passing the apikey obtained from your
|
||||
/// project dashboard.
|
||||
final client = Client('b67pax5b2wdq');
|
||||
final client = StreamChatClient('b67pax5b2wdq');
|
||||
|
||||
/// Set the current user. In a production scenario, this should be done using
|
||||
/// a backend to generate a user token using our server SDK.
|
||||
@@ -48,9 +48,9 @@ class StreamExample extends StatelessWidget {
|
||||
@required this.channel,
|
||||
}) : super(key: key);
|
||||
|
||||
/// Instance of [Client] we created earlier. This contains information about
|
||||
/// Instance of [StreamChatClient] we created earlier. This contains information about
|
||||
/// our application and connection state.
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
/// The channel we'd like to observe and participate.
|
||||
final Channel channel;
|
||||
@@ -242,7 +242,7 @@ class _MessageViewState extends State<MessageView> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper extension for quickly retrieving the current user id from a [Client].
|
||||
extension on Client {
|
||||
/// Helper extension for quickly retrieving the current user id from a [StreamChatClient].
|
||||
extension on StreamChatClient {
|
||||
String get uid => state.user.id;
|
||||
}
|
||||
|
||||
@@ -160,8 +160,8 @@ class Channel {
|
||||
state?.channelStateStream?.map((cs) => cs.channel?.extraData);
|
||||
|
||||
/// The main Stream chat client
|
||||
Client get client => _client;
|
||||
final Client _client;
|
||||
StreamChatClient get client => _client;
|
||||
final StreamChatClient _client;
|
||||
|
||||
String get _channelURL => '/channels/$type/$id';
|
||||
|
||||
@@ -722,7 +722,7 @@ class Channel {
|
||||
});
|
||||
}
|
||||
|
||||
/// Hides the channel from [Client.queryChannels] for the user until a message is added
|
||||
/// Hides the channel from [StreamChatClient.queryChannels] for the user until a message is added
|
||||
/// If [clearHistory] is set to true - all messages will be removed for the user
|
||||
Future<EmptyResponse> hide({bool clearHistory = false}) async {
|
||||
_checkInitialized();
|
||||
|
||||
@@ -17,7 +17,7 @@ class _BaseResponse {
|
||||
String duration;
|
||||
}
|
||||
|
||||
/// Model response for [Client.resync] api call
|
||||
/// Model response for [StreamChatClient.resync] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class SyncResponse extends _BaseResponse {
|
||||
/// The list of events
|
||||
@@ -28,7 +28,7 @@ class SyncResponse extends _BaseResponse {
|
||||
_$SyncResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.queryChannels] api call
|
||||
/// Model response for [StreamChatClient.queryChannels] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class QueryChannelsResponse extends _BaseResponse {
|
||||
/// List of channels state returned by the query
|
||||
@@ -39,7 +39,7 @@ class QueryChannelsResponse extends _BaseResponse {
|
||||
_$QueryChannelsResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.queryChannels] api call
|
||||
/// Model response for [StreamChatClient.queryChannels] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class TranslateMessageResponse extends _BaseResponse {
|
||||
/// List of channels state returned by the query
|
||||
@@ -50,7 +50,7 @@ class TranslateMessageResponse extends _BaseResponse {
|
||||
_$TranslateMessageResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.queryChannels] api call
|
||||
/// Model response for [StreamChatClient.queryChannels] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class QueryMembersResponse extends _BaseResponse {
|
||||
/// List of channels state returned by the query
|
||||
@@ -61,7 +61,7 @@ class QueryMembersResponse extends _BaseResponse {
|
||||
_$QueryMembersResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.queryUsers] api call
|
||||
/// Model response for [StreamChatClient.queryUsers] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class QueryUsersResponse extends _BaseResponse {
|
||||
/// List of users returned by the query
|
||||
@@ -94,7 +94,7 @@ class QueryRepliesResponse extends _BaseResponse {
|
||||
_$QueryRepliesResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.getDevices] api call
|
||||
/// Model response for [StreamChatClient.getDevices] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class ListDevicesResponse extends _BaseResponse {
|
||||
/// List of user devices
|
||||
@@ -141,7 +141,7 @@ class SendReactionResponse extends _BaseResponse {
|
||||
_$SendReactionResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.setGuestUser] api call
|
||||
/// Model response for [StreamChatClient.setGuestUser] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class SetGuestUserResponse extends _BaseResponse {
|
||||
/// Guest user access token
|
||||
@@ -155,7 +155,7 @@ class SetGuestUserResponse extends _BaseResponse {
|
||||
_$SetGuestUserResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.updateUser] api call
|
||||
/// Model response for [StreamChatClient.updateUser] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class UpdateUsersResponse extends _BaseResponse {
|
||||
/// Updated users
|
||||
@@ -166,7 +166,7 @@ class UpdateUsersResponse extends _BaseResponse {
|
||||
_$UpdateUsersResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.updateMessage] api call
|
||||
/// Model response for [StreamChatClient.updateMessage] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class UpdateMessageResponse extends _BaseResponse {
|
||||
/// Message returned by the api call
|
||||
@@ -188,7 +188,7 @@ class SendMessageResponse extends _BaseResponse {
|
||||
_$SendMessageResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.getMessage] api call
|
||||
/// Model response for [StreamChatClient.getMessage] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class GetMessageResponse extends _BaseResponse {
|
||||
/// Message returned by the api call
|
||||
@@ -208,7 +208,7 @@ class GetMessageResponse extends _BaseResponse {
|
||||
}
|
||||
}
|
||||
|
||||
/// Model response for [Client.search] api call
|
||||
/// Model response for [StreamChatClient.search] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class SearchMessagesResponse extends _BaseResponse {
|
||||
/// List of messages returned by the api call
|
||||
|
||||
@@ -15,17 +15,18 @@ class RetryPolicy {
|
||||
int attempt = 0;
|
||||
|
||||
/// This function evaluates if we should retry the failure
|
||||
final bool Function(Client client, int attempt, ApiError apiError)
|
||||
final bool Function(StreamChatClient client, int attempt, ApiError apiError)
|
||||
shouldRetry;
|
||||
|
||||
/// In the case that we want to retry a failed request the retryTimeout method is called to determine the timeout
|
||||
final Duration Function(Client client, int attempt, ApiError apiError)
|
||||
retryTimeout;
|
||||
final Duration Function(
|
||||
StreamChatClient client, int attempt, ApiError apiError) retryTimeout;
|
||||
|
||||
/// Creates a copy of [RetryPolicy] with specified attributes overridden.
|
||||
RetryPolicy copyWith({
|
||||
bool Function(Client client, int attempt, ApiError apiError) shouldRetry,
|
||||
Duration Function(Client client, int attempt, ApiError apiError)
|
||||
bool Function(StreamChatClient client, int attempt, ApiError apiError)
|
||||
shouldRetry,
|
||||
Duration Function(StreamChatClient client, int attempt, ApiError apiError)
|
||||
retryTimeout,
|
||||
int attempt,
|
||||
}) =>
|
||||
|
||||
@@ -3,15 +3,15 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:pedantic/pedantic.dart' show unawaited;
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:stream_chat/src/api/retry_policy.dart';
|
||||
import 'package:stream_chat/src/event_type.dart';
|
||||
import 'package:stream_chat/src/models/own_user.dart';
|
||||
import 'package:stream_chat/version.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:pedantic/pedantic.dart' show unawaited;
|
||||
|
||||
import 'api/channel.dart';
|
||||
import 'api/connection_status.dart';
|
||||
@@ -64,12 +64,12 @@ extension on PushProvider {
|
||||
/// websocket connection to Stream Chat servers.
|
||||
///
|
||||
/// ```dart
|
||||
/// final client = Client("stream-chat-api-key");
|
||||
/// final client = StreamChatClient("stream-chat-api-key");
|
||||
/// ```
|
||||
class Client {
|
||||
class StreamChatClient {
|
||||
/// Create a client instance with default options.
|
||||
/// You should only create the client once and re-use it across your application.
|
||||
Client(
|
||||
StreamChatClient(
|
||||
this.apiKey, {
|
||||
this.tokenProvider,
|
||||
this.baseURL = _defaultBaseURL,
|
||||
@@ -81,9 +81,10 @@ class Client {
|
||||
RetryPolicy retryPolicy,
|
||||
}) {
|
||||
_retryPolicy ??= RetryPolicy(
|
||||
retryTimeout: (Client client, int attempt, ApiError error) =>
|
||||
retryTimeout: (StreamChatClient client, int attempt, ApiError error) =>
|
||||
Duration(seconds: 1 * attempt),
|
||||
shouldRetry: (Client client, int attempt, ApiError error) => attempt < 5,
|
||||
shouldRetry: (StreamChatClient client, int attempt, ApiError error) =>
|
||||
attempt < 5,
|
||||
);
|
||||
|
||||
state = ClientState(this);
|
||||
@@ -94,7 +95,7 @@ class Client {
|
||||
logger.info('instantiating new client');
|
||||
}
|
||||
|
||||
/// Client chat persistence client
|
||||
/// Chat persistence client
|
||||
ChatPersistenceClient chatPersistenceClient;
|
||||
|
||||
/// Whether the chat persistence is available or not
|
||||
@@ -110,11 +111,11 @@ class Client {
|
||||
/// This client state
|
||||
ClientState state;
|
||||
|
||||
/// By default the Chat Client will write all messages with level Warn or Error to stdout.
|
||||
/// By default the Chat client will write all messages with level Warn or Error to stdout.
|
||||
/// During development you might want to enable more logging information, you can change the default log level when constructing the client.
|
||||
///
|
||||
/// ```dart
|
||||
/// final client = Client("stream-chat-api-key", logLevel: Level.INFO);
|
||||
/// final client = StreamChatClient("stream-chat-api-key", logLevel: Level.INFO);
|
||||
/// ```
|
||||
final Level logLevel;
|
||||
|
||||
@@ -133,7 +134,7 @@ class Client {
|
||||
/// // do something with the record (ie. send it to Sentry or Fabric)
|
||||
/// }
|
||||
///
|
||||
/// final client = Client("stream-chat-api-key", logHandlerFunction: myLogHandlerFunction);
|
||||
/// final client = StreamChatClient("stream-chat-api-key", logHandlerFunction: myLogHandlerFunction);
|
||||
///```
|
||||
LogHandlerFunction logHandlerFunction;
|
||||
|
||||
@@ -1337,7 +1338,7 @@ class ClientState {
|
||||
}));
|
||||
}
|
||||
|
||||
final Client _client;
|
||||
final StreamChatClient _client;
|
||||
|
||||
/// Update user information
|
||||
set user(OwnUser user) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:stream_chat/src/client.dart';
|
||||
|
||||
/// Current package version
|
||||
/// Used in [Client] to build the `x-stream-client` header
|
||||
/// Used in [StreamChatClient] to build the `x-stream-client` header
|
||||
const PACKAGE_VERSION = '0.2.24+2';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dio/native_imp.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:stream_chat/src/api/requests.dart';
|
||||
import 'package:stream_chat/src/client.dart';
|
||||
@@ -8,6 +7,7 @@ import 'package:stream_chat/src/event_type.dart';
|
||||
import 'package:stream_chat/src/models/event.dart';
|
||||
import 'package:stream_chat/src/models/message.dart';
|
||||
import 'package:stream_chat/src/models/reaction.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
class MockDio extends Mock implements DioForNative {}
|
||||
|
||||
@@ -22,7 +22,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -51,7 +51,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -83,7 +83,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -108,7 +108,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -149,7 +149,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -173,7 +173,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -198,7 +198,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -223,7 +223,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -247,7 +247,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -272,7 +272,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -306,7 +306,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -340,7 +340,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -375,7 +375,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -414,7 +414,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -448,7 +448,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -475,7 +475,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -501,7 +501,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -527,7 +527,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -845,7 +845,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1159,7 +1159,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1474,7 +1474,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1789,7 +1789,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1815,7 +1815,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1842,7 +1842,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1863,7 +1863,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1885,7 +1885,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1910,7 +1910,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1935,7 +1935,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1961,7 +1961,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -1993,7 +1993,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -2024,7 +2024,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
@@ -2064,7 +2064,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
tokenProvider: (_) async => '',
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'dart:convert';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dio/native_imp.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:stream_chat/src/api/requests.dart';
|
||||
@@ -11,6 +10,7 @@ import 'package:stream_chat/src/client.dart';
|
||||
import 'package:stream_chat/src/exceptions.dart';
|
||||
import 'package:stream_chat/src/models/message.dart';
|
||||
import 'package:stream_chat/src/models/user.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
class MockDio extends Mock implements DioForNative {}
|
||||
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('should create the object correctly', () {
|
||||
final client = Client('api-key');
|
||||
final client = StreamChatClient('api-key');
|
||||
|
||||
expect(client.baseURL, 'chat-us-east-1.stream-io-api.com');
|
||||
expect(client.apiKey, 'api-key');
|
||||
@@ -55,7 +55,7 @@ void main() {
|
||||
print(record.message);
|
||||
};
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
connectTimeout: Duration(seconds: 10),
|
||||
receiveTimeout: Duration(seconds: 12),
|
||||
@@ -78,7 +78,7 @@ void main() {
|
||||
}));
|
||||
|
||||
test('Channel', () {
|
||||
final client = Client('test');
|
||||
final client = StreamChatClient('test');
|
||||
final Map<String, dynamic> data = {'test': 1};
|
||||
final channelClient = client.channel('type', id: 'id', extraData: data);
|
||||
expect(channelClient.type, 'type');
|
||||
@@ -93,7 +93,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -124,7 +124,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -175,7 +175,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -203,7 +203,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -247,7 +247,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -273,7 +273,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -292,7 +292,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -309,7 +309,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('devToken', () {
|
||||
final client = Client('api-key');
|
||||
final client = StreamChatClient('api-key');
|
||||
final token = client.devToken('test');
|
||||
|
||||
expect(
|
||||
@@ -325,7 +325,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -353,7 +353,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -396,7 +396,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -417,7 +417,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -432,7 +432,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -453,7 +453,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -478,7 +478,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -507,7 +507,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -528,7 +528,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -550,7 +550,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -571,7 +571,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -594,7 +594,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -615,7 +615,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -636,7 +636,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -663,7 +663,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -684,7 +684,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -705,7 +705,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -727,7 +727,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -752,7 +752,7 @@ void main() {
|
||||
final mockHttpClientAdapter = MockHttpClientAdapter();
|
||||
dioHttp.httpClientAdapter = mockHttpClientAdapter;
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: dioHttp,
|
||||
);
|
||||
@@ -771,7 +771,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -794,7 +794,7 @@ void main() {
|
||||
final mockHttpClientAdapter = MockHttpClientAdapter();
|
||||
dioHttp.httpClientAdapter = mockHttpClientAdapter;
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: dioHttp,
|
||||
);
|
||||
@@ -813,7 +813,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -836,7 +836,7 @@ void main() {
|
||||
final mockHttpClientAdapter = MockHttpClientAdapter();
|
||||
dioHttp.httpClientAdapter = mockHttpClientAdapter;
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: dioHttp,
|
||||
);
|
||||
@@ -855,7 +855,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -879,7 +879,7 @@ void main() {
|
||||
final mockHttpClientAdapter = MockHttpClientAdapter();
|
||||
dioHttp.httpClientAdapter = mockHttpClientAdapter;
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: dioHttp,
|
||||
);
|
||||
@@ -898,7 +898,7 @@ void main() {
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
@@ -923,7 +923,7 @@ void main() {
|
||||
final mockHttpClientAdapter = MockHttpClientAdapter();
|
||||
dioHttp.httpClientAdapter = mockHttpClientAdapter;
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: dioHttp,
|
||||
);
|
||||
|
||||
@@ -91,7 +91,7 @@ Out of the box, all chat widgets use their default styling, and there are two wa
|
||||
1. Initialize the `StreamChatTheme` from your existing `MaterialApp` style
|
||||
```dart
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
@@ -117,7 +117,7 @@ Out of the box, all chat widgets use their default styling, and there are two wa
|
||||
2. Construct a custom theme and provide all the customizations needed
|
||||
```dart
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ class _AdvancedOptionsPageState extends State<AdvancedOptionsPage> {
|
||||
),
|
||||
);
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
apiKey,
|
||||
logLevel: Level.INFO,
|
||||
)..chatPersistenceClient = chatPersistentClient;
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
/// you can use [StreamChat.of], [StreamChannel.of] and [StreamChatTheme.of] to use the API client directly
|
||||
/// or to retrieve outer scope needed such as messages from the [Channel.state].
|
||||
void main() async {
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
's2dxdhpxd94g',
|
||||
logLevel: Level.INFO,
|
||||
);
|
||||
@@ -29,7 +29,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
/// We also change the message color posted by the current user.
|
||||
/// You can perform these more granular style changes using [StreamChatTheme.copyWith].
|
||||
void main() async {
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
's2dxdhpxd94g',
|
||||
logLevel: Level.INFO,
|
||||
);
|
||||
@@ -33,7 +33,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
///
|
||||
/// - We retrieve the count of unread messages from [Channel.state]
|
||||
void main() async {
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
's2dxdhpxd94g',
|
||||
logLevel: Level.INFO,
|
||||
);
|
||||
@@ -34,7 +34,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
/// you can use [StreamChat.of], [StreamChannel.of] and [StreamChatTheme.of] to use the API client directly
|
||||
/// or to retrieve outer scope needed such as messages from the [Channel.state].
|
||||
void main() async {
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
's2dxdhpxd94g',
|
||||
logLevel: Level.INFO,
|
||||
);
|
||||
@@ -29,7 +29,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ void main() async {
|
||||
final apiKey = await secureStorage.read(key: kStreamApiKey);
|
||||
final userId = await secureStorage.read(key: kStreamUserId);
|
||||
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
apiKey ?? kDefaultStreamApiKey,
|
||||
logLevel: Level.INFO,
|
||||
)..chatPersistenceClient = chatPersistentClient;
|
||||
@@ -46,7 +46,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
/// In this case we are showing the list of channels the current user is a member and we order them based on the time they had a new message.
|
||||
/// [ChannelListView] handles pagination and updates automatically out of the box when new channels are created or when a new message is added to a channel.
|
||||
void main() async {
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
's2dxdhpxd94g',
|
||||
logLevel: Level.INFO,
|
||||
);
|
||||
@@ -33,7 +33,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
///
|
||||
/// There are three important things to notice that are common to all Flutter application using StreamChat:
|
||||
///
|
||||
/// 1. The Dart API [Client] is initialized with your API Key
|
||||
/// 2. The current user is set by calling [Client.setUser]
|
||||
/// 1. The Dart API [StreamChatClient] is initialized with your API Key
|
||||
/// 2. The current user is set by calling [StreamChatClient.setUser]
|
||||
/// 3. The client is then passed to the top-level [StreamChat] widget
|
||||
/// [StreamChat] is an inherited widget and must be the parent of all Chat related widgets.
|
||||
///
|
||||
@@ -15,9 +15,9 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
///
|
||||
/// Let's have a look at what we've built:
|
||||
///
|
||||
/// - We set up the Chat [Client] with the API key
|
||||
/// - We set up the Chat [StreamChatClient] with the API key
|
||||
///
|
||||
/// - We set the the current user for Chat with [Client.setUser] and a pre-generated user token
|
||||
/// - We set the the current user for Chat with [StreamChatClient.setUser] and a pre-generated user token
|
||||
///
|
||||
/// - We make [StreamChat] the root Widget of our application
|
||||
///
|
||||
@@ -25,7 +25,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
///
|
||||
/// If you now run the simulator you will see a single channel UI.
|
||||
void main() async {
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
's2dxdhpxd94g',
|
||||
logLevel: Level.INFO,
|
||||
);
|
||||
@@ -44,7 +44,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
final Channel channel;
|
||||
|
||||
MyApp(this.client, this.channel);
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() async {
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
's2dxdhpxd94g',
|
||||
logLevel: Level.INFO,
|
||||
);
|
||||
@@ -16,7 +16,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
///
|
||||
/// Now we can open threads and create new ones as well, if you long press a message you can tap on Reply and it will open the same [ThreadPage].
|
||||
void main() async {
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
's2dxdhpxd94g',
|
||||
logLevel: Level.INFO,
|
||||
);
|
||||
@@ -24,7 +24,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
MyApp(this.client);
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
import 'package:stream_chat_flutter/src/back_button.dart';
|
||||
import 'package:stream_chat_flutter/src/channel_info.dart';
|
||||
import 'package:stream_chat_flutter/src/channel_name.dart';
|
||||
import 'package:stream_chat_flutter/src/info_tile.dart';
|
||||
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
import '../stream_chat_flutter.dart';
|
||||
import './channel_name.dart';
|
||||
import '../stream_chat_flutter.dart';
|
||||
import 'channel_image.dart';
|
||||
import 'connection_status_builder.dart';
|
||||
|
||||
@@ -18,7 +18,7 @@ import 'connection_status_builder.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// final Client client;
|
||||
/// final StreamChatClient client;
|
||||
/// final Channel channel;
|
||||
///
|
||||
/// MyApp(this.client, this.channel);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
import 'package:stream_chat_flutter/src/group_image.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
/// 
|
||||
/// 
|
||||
@@ -11,7 +11,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// final Client client;
|
||||
/// final StreamChatClient client;
|
||||
/// final Channel channel;
|
||||
///
|
||||
/// MyApp(this.client, this.channel);
|
||||
|
||||
@@ -111,7 +111,8 @@ class ChannelInfo extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDisconnectedTitleState(BuildContext context, Client client) {
|
||||
Widget _buildDisconnectedTitleState(
|
||||
BuildContext context, StreamChatClient client) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
@@ -2,9 +2,9 @@ import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
import 'package:stream_chat_flutter/src/stream_neumorphic_button.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
import 'connection_status_builder.dart';
|
||||
import 'info_tile.dart';
|
||||
@@ -13,15 +13,15 @@ import 'stream_chat.dart';
|
||||
typedef _TitleBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
ConnectionStatus status,
|
||||
Client client,
|
||||
StreamChatClient client,
|
||||
);
|
||||
|
||||
///
|
||||
/// It shows the current [Client] status.
|
||||
/// It shows the current [StreamChatClient] status.
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// final Client client;
|
||||
/// final StreamChatClient client;
|
||||
///
|
||||
/// MyApp(this.client);
|
||||
///
|
||||
@@ -42,8 +42,8 @@ typedef _TitleBuilder = Widget Function(
|
||||
/// Usually you would use this widget as an [AppBar] inside a [Scaffold].
|
||||
/// However you can also use it as a normal widget.
|
||||
///
|
||||
/// The widget by default uses the inherited [Client] to fetch information about the status.
|
||||
/// However you can also pass your own [Client] if you don't have it in the widget tree.
|
||||
/// The widget by default uses the inherited [StreamChatClient] to fetch information about the status.
|
||||
/// However you can also pass your own [StreamChatClient] if you don't have it in the widget tree.
|
||||
///
|
||||
/// The widget components render the ui based on the first ancestor of type [StreamChatTheme] and on its [ChannelTheme.channelHeaderTheme] property.
|
||||
/// Modify it to change the widget appearance.
|
||||
@@ -59,8 +59,8 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
|
||||
this.preNavigationCallback,
|
||||
}) : super(key: key);
|
||||
|
||||
/// Pass this if you don't have a [Client] in your widget tree.
|
||||
final Client client;
|
||||
/// Pass this if you don't have a [StreamChatClient] in your widget tree.
|
||||
final StreamChatClient client;
|
||||
|
||||
/// Use this to build your own title as per different [ConnectionStatus]
|
||||
final _TitleBuilder titleBuilder;
|
||||
@@ -215,7 +215,8 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDisconnectedTitleState(BuildContext context, Client client) {
|
||||
Widget _buildDisconnectedTitleState(
|
||||
BuildContext context, StreamChatClient client) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
import 'stream_chat.dart';
|
||||
|
||||
/// Widget that builds itself based on the latest snapshot of interaction with
|
||||
/// a [Stream] of type [ConnectionStatus].
|
||||
///
|
||||
/// The widget will use the closest [Client.wsConnectionStatusStream] in case no
|
||||
/// The widget will use the closest [StreamChatClient.wsConnectionStatusStream] in case no
|
||||
/// stream is provided.
|
||||
class ConnectionStatusBuilder extends StatelessWidget {
|
||||
/// Creates a new ConnectionStatusBuilder
|
||||
|
||||
@@ -4,14 +4,14 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_app_badger/flutter_app_badger.dart';
|
||||
import 'package:flutter_portal/flutter_portal.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
/// Widget used to provide information about the chat to the widget tree
|
||||
///
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// final Client client;
|
||||
/// final StreamChatClient client;
|
||||
///
|
||||
/// MyApp(this.client);
|
||||
///
|
||||
@@ -30,7 +30,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
///
|
||||
/// Use [StreamChat.of] to get the current [StreamChatState] instance.
|
||||
class StreamChat extends StatefulWidget {
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
final Widget child;
|
||||
final StreamChatThemeData streamChatThemeData;
|
||||
|
||||
@@ -73,7 +73,7 @@ class StreamChat extends StatefulWidget {
|
||||
|
||||
/// The current state of the StreamChat widget
|
||||
class StreamChatState extends State<StreamChat> {
|
||||
Client get client => widget.client;
|
||||
StreamChatClient get client => widget.client;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
class MockClient extends Mock implements Client {}
|
||||
class MockClient extends Mock implements StreamChatClient {}
|
||||
|
||||
class MockClientState extends Mock implements ClientState {}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
/// Create a new instance of [Client] passing the apikey obtained from your
|
||||
/// Create a new instance of [StreamChatClient] passing the apikey obtained from your
|
||||
/// project dashboard.
|
||||
final client = Client('b67pax5b2wdq');
|
||||
final client = StreamChatClient('b67pax5b2wdq');
|
||||
|
||||
/// Set the current user. In a production scenario, this should be done using
|
||||
/// a backend to generate a user token using our server SDK.
|
||||
@@ -43,10 +43,10 @@ class StreamExample extends StatelessWidget {
|
||||
}) : super(key: key);
|
||||
|
||||
/// Instance of Stream Client.
|
||||
/// Stream's [Client] can be used to connect to our servers and set the default
|
||||
/// Stream's [StreamChatClient] can be used to connect to our servers and set the default
|
||||
/// user for the application. Performing these actions trigger a websocket connection
|
||||
/// allowing for real-time updates.
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -287,8 +287,8 @@ class _MessageScreenState extends State<MessageScreen> {
|
||||
}
|
||||
|
||||
/// Extensions can be used to add functionality to the SDK. In the examples
|
||||
/// below, we add two simple extensions to the [Client] and [Channel].
|
||||
extension on Client {
|
||||
/// below, we add two simple extensions to the [StreamChatClient] and [Channel].
|
||||
extension on StreamChatClient {
|
||||
/// Fetches the current user id.
|
||||
String get uid => state.user.id;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class MessageSearchBlocState extends State<MessageSearchBloc>
|
||||
Stream<bool> get queryMessagesLoading =>
|
||||
_queryMessagesLoadingController.stream;
|
||||
|
||||
/// Calls [Client.search] updating [messageResponses] stream
|
||||
/// Calls [StreamChatClient.search] updating [messageResponses] stream
|
||||
Future<void> search({
|
||||
Map<String, dynamic> filter,
|
||||
Map<String, dynamic> messageFilter,
|
||||
@@ -82,7 +82,7 @@ class MessageSearchBlocState extends State<MessageSearchBloc>
|
||||
}
|
||||
}
|
||||
|
||||
/// Calls [Client.search] updating [queryMessagesLoading] stream
|
||||
/// Calls [StreamChatClient.search] updating [queryMessagesLoading] stream
|
||||
Future<void> loadMore({
|
||||
Map<String, dynamic> filter,
|
||||
Map<String, dynamic> messageFilter,
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'typedef.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// final Client client;
|
||||
/// final StreamChatClient client;
|
||||
///
|
||||
/// MyApp(this.client);
|
||||
///
|
||||
@@ -50,7 +50,7 @@ class StreamChatCore extends StatefulWidget {
|
||||
|
||||
/// Instance of Stream Chat Client containing information about the current
|
||||
/// application.
|
||||
final Client client;
|
||||
final StreamChatClient client;
|
||||
|
||||
/// Widget descendant.
|
||||
final Widget child;
|
||||
@@ -85,7 +85,7 @@ class StreamChatCore extends StatefulWidget {
|
||||
class StreamChatCoreState extends State<StreamChatCore>
|
||||
with WidgetsBindingObserver {
|
||||
/// Initialized client used throughout the application.
|
||||
Client get client => widget.client;
|
||||
StreamChatClient get client => widget.client;
|
||||
|
||||
Timer _disconnectTimer;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
|
||||
class MockClient extends Mock implements Client {}
|
||||
class MockClient extends Mock implements StreamChatClient {}
|
||||
|
||||
class MockClientState extends Mock implements ClientState {}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ final chatPersistentClient = StreamChatPersistenceClient(
|
||||
```
|
||||
2. Pass the instance to the official Stream chat client.
|
||||
```dart
|
||||
final client = Client(
|
||||
final client = StreamChatClient(
|
||||
apiKey ?? kDefaultStreamApiKey,
|
||||
logLevel: Level.INFO,
|
||||
)..chatPersistenceClient = chatPersistentClient;
|
||||
|
||||
Reference in New Issue
Block a user