diff --git a/README.md b/README.md
index 8d6d17ae..7ce74c78 100644
--- a/README.md
+++ b/README.md
@@ -17,11 +17,11 @@ Through Chat SDK for flutter, you can efficiently integrate real-time chat into
### How it works
-It is simple to implement chat in your client app with Sendbird Chat SDK for Flutter: a user logs in, sees a list of channels, selects or creates an [open channel](https://sendbird.com/docs/chat/v3/ios/guides/open-channel) or a [group channel](https://sendbird.com/docs/chat/v3/ios/guides/group-channel), and, through the use of the [channel event handler](https://sendbird.com/docs/chat/v3/ios/guides/event-delegate), sends messages to the channel, while also receiving them from other users within the channel.
+It is simple to implement chat in your client app with Sendbird Chat SDK for Flutter: a user logs in, sees a list of channels, selects or creates an [open channel](https://sendbird.com/docs/chat/v3/flutter/guides/open-channel) or a [group channel](https://sendbird.com/docs/chat/v3/flutter/guides/group-channel), and, through the use of the [channel event handler](https://sendbird.com/docs/chat/v3/flutter/guides/event-handler), sends messages to the channel, while also receiving them from other users within the channel.
### More about Sendbird Chat SDK for flutter
-Find out more about Sendbird Chat for Flutter at [Sendbird Docs](). If you have any comments or questions regarding bugs and feature requests, visit [Sendbird community](https://community.sendbird.com).
+Find out more about Sendbird Chat for Flutter at [Sendbird Docs](https://sendbird.com/docs/chat/v3/flutter/getting-started/about-chat-sdk). If you have any comments or questions regarding bugs and feature requests, visit [Sendbird community](https://community.sendbird.com).
@@ -35,9 +35,7 @@ The minimum requirements for Chat SDK for Flutter are:
- Xcode or Android studio
- Dart 2.10.4
-- Flutter 1.22.x
-
->__Note__: Flutter 2.0.x aren't compatible yet.
+- Flutter 1.22.x or higher
## Getting started
@@ -146,7 +144,7 @@ For security reasons, you can also use a session token when a user logs in to Se
### Step 3: Create a new open channel
-Create an [open channel](https://sendbird.com/docs/chat/v3/ios/guides/open-channel#2-create-a-channel). Once created, all users in your Sendbird application can easily participate in the channel.
+Create an [open channel](https://sendbird.com/docs/chat/v3/flutter/guides/open-channel#2-create-a-channel). Once created, all users in your Sendbird application can easily participate in the channel.
```dart
try {
@@ -156,7 +154,7 @@ try {
}
```
-You can also create a [group channel](https://sendbird.com/docs/chat/v3/ios/guides/group-channel#2-create-a-channel) by [inviting users as new members](https://sendbird.com/docs/chat/v3/ios/guides/group-channel#2-invite-users-as-members) to the channel.
+You can also create a [group channel](https://sendbird.com/docs/chat/v3/flutter/guides/group-channel#2-create-a-channel) by [inviting users as new members](https://sendbird.com/docs/chat/v3/flutter/guides/group-channel#2-invite-users-as-members) to the channel.
> Note: The majority of the methods used in the following steps are all asynchronous. This means, with asynchronous methods, your client app must receive a result via `await` or `then()` callbacks from Sendbird server through completion handlers before moving on to the next step.
diff --git a/analysis_options.yaml b/analysis_options.yaml
new file mode 100644
index 00000000..60b9fbbf
--- /dev/null
+++ b/analysis_options.yaml
@@ -0,0 +1,17 @@
+# Defines a default set of lint rules enforced for
+# projects at Google. For details and rationale,
+# see https://github.com/dart-lang/pedantic#enabled-lints.
+include: package:pedantic/analysis_options.yaml
+
+# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
+# Uncomment to specify additional rules.
+linter:
+ rules:
+ prefer_final_fields: false
+ unawaited_futures: false
+
+analyzer:
+ exclude:
+ - example
+ - lib/**/*.g.dart
+ - lib/params/message_change_logs_params.g.dart
\ No newline at end of file
diff --git a/example/main.dart b/example/main.dart
new file mode 100644
index 00000000..0d943597
--- /dev/null
+++ b/example/main.dart
@@ -0,0 +1,29 @@
+import 'package:sendbird_sdk/sendbird_sdk.dart';
+
+void main(List arguments) async {
+ // This example uses the Google Books API to search for books about http.
+ // https://developers.google.com/books/docs/overview
+
+ final sendbird = SendbirdSdk(appId: 'YOUR-APP-ID');
+
+ try {
+ final user = await sendbird.connect('UNIQUE-USER-ID');
+ final params = GroupChannelParams()
+ ..userIds = [user.userId]
+ ..operatorUserIds = [user.userId]
+ ..name = 'YOUR_GROUP_NAME'
+ ..customType = 'CUSTOM_TYPE'
+ ..isPublic = true;
+
+ // create group channel
+ final channel = await GroupChannel.createChannel(params);
+
+ channel.sendUserMessageWithText('Hello World',
+ onCompleted: (message, error) {
+ // message has been sent successfully
+ print('${message.message} has been sent!');
+ });
+ } catch (e) {
+ // handle error
+ }
+}
diff --git a/lib/constant/enums.dart b/lib/constant/enums.dart
index da4ffbcb..9667af44 100644
--- a/lib/constant/enums.dart
+++ b/lib/constant/enums.dart
@@ -19,9 +19,9 @@ extension ChannelTypeExtension on ChannelType {
String get urlString {
switch (this) {
case ChannelType.group:
- return "group_channels";
+ return 'group_channels';
case ChannelType.open:
- return "open_channels";
+ return 'open_channels';
default:
return null;
}
@@ -52,7 +52,7 @@ enum Role {
none,
/// Operator
- @JsonValue("operator")
+ @JsonValue('operator')
chat_operator
}
@@ -499,13 +499,12 @@ enum ChannelQueryIncludeOption {
extension IncludeOptionList on List {
Map toJson() {
- final hasEmpty = this.contains(ChannelQueryIncludeOption.emptyChannel);
- final hasMember = this.contains(ChannelQueryIncludeOption.memberList);
- final hasFrozen = this.contains(ChannelQueryIncludeOption.frozenChannel);
- final hasRead = this.contains(ChannelQueryIncludeOption.readReceipt);
- final hasDelivery =
- this.contains(ChannelQueryIncludeOption.deliveryReceipt);
- final hasMeta = this.contains(ChannelQueryIncludeOption.metaData);
+ final hasEmpty = contains(ChannelQueryIncludeOption.emptyChannel);
+ final hasMember = contains(ChannelQueryIncludeOption.memberList);
+ final hasFrozen = contains(ChannelQueryIncludeOption.frozenChannel);
+ final hasRead = contains(ChannelQueryIncludeOption.readReceipt);
+ final hasDelivery = contains(ChannelQueryIncludeOption.deliveryReceipt);
+ final hasMeta = contains(ChannelQueryIncludeOption.metaData);
return {
if (hasEmpty) 'show_empty': true,
diff --git a/lib/constant/types.dart b/lib/constant/types.dart
index dc7ad304..d93614b2 100644
--- a/lib/constant/types.dart
+++ b/lib/constant/types.dart
@@ -1,7 +1,8 @@
import 'package:sendbird_sdk/core/message/base_message.dart';
import 'package:sendbird_sdk/core/message/file_message.dart';
+import 'package:sendbird_sdk/core/message/user_message.dart';
-typedef void OnUploadProgressCallback(int sentBytes, int totalBytes);
-typedef void OnMessageCallback(BaseMessage message, Error error);
-typedef void OnFileMessageCallback(FileMessage message, Error error);
-typedef void OnUserMessageCallback(FileMessage message, Error error);
+typedef OnUploadProgressCallback = void Function(int sentBytes, int totalBytes);
+typedef OnMessageCallback = void Function(BaseMessage message, Error error);
+typedef OnFileMessageCallback = void Function(FileMessage message, Error error);
+typedef OnUserMessageCallback = void Function(UserMessage message, Error error);
diff --git a/lib/core/channel/base/base_channel.dart b/lib/core/channel/base/base_channel.dart
index f50bf54c..c2bb6925 100644
--- a/lib/core/channel/base/base_channel.dart
+++ b/lib/core/channel/base/base_channel.dart
@@ -76,7 +76,8 @@ class BaseChannel implements Cacheable {
bool fromCache = false;
@JsonKey(ignore: true)
- bool dirty = false;
+ @override
+ bool dirty;
/// **WARNING:** Do not use default constructor to initialize manually
BaseChannel({
diff --git a/lib/core/channel/base/base_channel_messages.dart b/lib/core/channel/base/base_channel_messages.dart
index 0493c575..7077ac11 100644
--- a/lib/core/channel/base/base_channel_messages.dart
+++ b/lib/core/channel/base/base_channel_messages.dart
@@ -10,7 +10,7 @@ extension Messages on BaseChannel {
/// on all other members' end.
UserMessage sendUserMessageWithText(
String text, {
- OnMessageCallback onCompleted,
+ OnUserMessageCallback onCompleted,
}) {
final params = UserMessageParams()..message = text;
return sendUserMessage(
@@ -27,7 +27,7 @@ extension Messages on BaseChannel {
/// on all other members' end.
UserMessage sendUserMessage(
UserMessageParams params, {
- OnMessageCallback onCompleted,
+ OnUserMessageCallback onCompleted,
}) {
if (params.message == null || params.message.isEmpty) {
throw InvalidParameterError();
@@ -77,7 +77,7 @@ extension Messages on BaseChannel {
/// on all other members' end.
UserMessage resendUserMessage(
UserMessage message, {
- OnMessageCallback onCompleted,
+ OnUserMessageCallback onCompleted,
}) {
if (message == null ||
message.sendingStatus != MessageSendingStatus.failed) {
@@ -118,7 +118,7 @@ extension Messages on BaseChannel {
final msg = BaseMessage.msgFromJson(res.payload);
return msg;
} catch (e) {
- throw e;
+ rethrow;
}
}
@@ -162,7 +162,7 @@ extension Messages on BaseChannel {
Duration(seconds: _sdk.options.fileTransferTimeout),
onTimeout: () {
logger.e('upload timeout');
- if (onCompleted != null)
+ if (onCompleted != null) {
onCompleted(
pending..sendingStatus = MessageSendingStatus.failed,
SBError(
@@ -170,6 +170,7 @@ extension Messages on BaseChannel {
code: ErrorCode.fileUploadTimeout,
),
);
+ }
return;
},
);
@@ -272,7 +273,7 @@ extension Messages on BaseChannel {
final msg = BaseMessage.msgFromJson(res.payload);
return msg;
} catch (e) {
- throw e;
+ rethrow;
}
}
@@ -364,8 +365,9 @@ extension Messages on BaseChannel {
throw InvalidParameterError();
}
- if (channelType == ChannelType.group)
+ if (channelType == ChannelType.group) {
params.showSubChannelMessagesOnly = false;
+ }
return _sdk.api.getMessages(
channelType: channelType,
@@ -387,8 +389,9 @@ extension Messages on BaseChannel {
throw InvalidParameterError();
}
- if (channelType == ChannelType.group)
+ if (channelType == ChannelType.group) {
params.showSubChannelMessagesOnly = false;
+ }
return _sdk.api.getMessages(
channelType: channelType,
diff --git a/lib/core/channel/base/base_channel_meta.dart b/lib/core/channel/base/base_channel_meta.dart
index f27cb8c6..e8b4480a 100644
--- a/lib/core/channel/base/base_channel_meta.dart
+++ b/lib/core/channel/base/base_channel_meta.dart
@@ -309,7 +309,7 @@ extension Meta on BaseChannel {
throw InvalidParameterError();
}
- if (metaArrays == null || metaArrays.length == 0) {
+ if (metaArrays == null || metaArrays.isEmpty) {
throw InvalidParameterError();
}
@@ -330,7 +330,7 @@ extension Meta on BaseChannel {
throw InvalidParameterError();
}
- if (keys == null || keys.length <= 0) {
+ if (keys == null || keys.isEmpty) {
throw InvalidParameterError();
}
@@ -353,7 +353,7 @@ extension Meta on BaseChannel {
throw InvalidParameterError();
}
- if (metaArrays == null || metaArrays.length == 0) {
+ if (metaArrays == null || metaArrays.isEmpty) {
throw InvalidParameterError();
}
diff --git a/lib/core/channel/group/features/delivery_status.dart b/lib/core/channel/group/features/delivery_status.dart
index bd61c4be..d70fa81f 100644
--- a/lib/core/channel/group/features/delivery_status.dart
+++ b/lib/core/channel/group/features/delivery_status.dart
@@ -8,10 +8,11 @@ part 'delivery_status.g.dart';
class DeliveryStatus implements Cacheable {
final String channelUrl;
- @JsonKey(name: "updated")
+ @JsonKey(name: 'updated')
Map updatedDeliveryReceipt;
@JsonKey(ignore: true)
+ @override
bool dirty = false;
DeliveryStatus({
@@ -30,7 +31,8 @@ class DeliveryStatus implements Cacheable {
@override
void copyWith(dynamic others) {
- if (others is DeliveryStatus)
+ if (others is DeliveryStatus) {
updatedDeliveryReceipt.addAll(others.updatedDeliveryReceipt);
+ }
}
}
diff --git a/lib/core/channel/group/features/read_status.dart b/lib/core/channel/group/features/read_status.dart
index 6f3c0f86..08415ae2 100644
--- a/lib/core/channel/group/features/read_status.dart
+++ b/lib/core/channel/group/features/read_status.dart
@@ -23,6 +23,7 @@ class ReadStatus implements Cacheable {
int timestamp;
@JsonKey(ignore: true)
+ @override
bool dirty = false;
ReadStatus({
diff --git a/lib/core/channel/group/features/typing_status.dart b/lib/core/channel/group/features/typing_status.dart
index 1b1b27c2..29a7507a 100644
--- a/lib/core/channel/group/features/typing_status.dart
+++ b/lib/core/channel/group/features/typing_status.dart
@@ -9,6 +9,7 @@ class TypingStatus implements Cacheable {
User user;
int timestamp;
+ @override
bool dirty = false;
TypingStatus({
diff --git a/lib/core/channel/group/group_channel.dart b/lib/core/channel/group/group_channel.dart
index 0637a8a5..c50a67dd 100644
--- a/lib/core/channel/group/group_channel.dart
+++ b/lib/core/channel/group/group_channel.dart
@@ -264,9 +264,8 @@ class GroupChannel extends BaseChannel {
if (params == null) {
throw InvalidParameterError();
}
- if (params.channelUrl == null) {
- params.channelUrl = channelUrl;
- }
+ params.channelUrl ??= channelUrl;
+
if (params.channelUrl != channelUrl) {
throw InvalidParameterError();
}
diff --git a/lib/core/channel/group/group_channel_configuration.dart b/lib/core/channel/group/group_channel_configuration.dart
index 2283e190..e1af5157 100644
--- a/lib/core/channel/group/group_channel_configuration.dart
+++ b/lib/core/channel/group/group_channel_configuration.dart
@@ -17,7 +17,7 @@ extension GroupChannelConfiguration on GroupChannel {
);
if (offset != null) messageOffsetTimestamp = offset;
- if (hidePreviousMessage) this.clearUnreadCount();
+ if (hidePreviousMessage) clearUnreadCount();
isHidden = true;
hiddenState = allowAutoUnhide
diff --git a/lib/core/channel/group/group_channel_internal.dart b/lib/core/channel/group/group_channel_internal.dart
index c8eb1fb4..457c37d2 100644
--- a/lib/core/channel/group/group_channel_internal.dart
+++ b/lib/core/channel/group/group_channel_internal.dart
@@ -110,11 +110,11 @@ extension GroupChannelInternal on GroupChannel {
members.sort((a, b) => a.nickname.compareTo(b.nickname));
final ts = DateTime.now().millisecondsSinceEpoch;
- DeliveryStatus delivery = DeliveryStatus(
+ final delivery = DeliveryStatus(
channelUrl: channelUrl,
updatedDeliveryReceipt: {newMember.userId: ts},
);
- ReadStatus read = ReadStatus(
+ final read = ReadStatus(
channelType: channelType,
channelUrl: channelUrl,
timestamp: ts,
diff --git a/lib/core/channel/group/group_channel_typing.dart b/lib/core/channel/group/group_channel_typing.dart
index 6c23f2f9..a08b413a 100644
--- a/lib/core/channel/group/group_channel_typing.dart
+++ b/lib/core/channel/group/group_channel_typing.dart
@@ -35,7 +35,7 @@ extension GroupChannelTyping on GroupChannel {
bool get isTyping {
final typingStatuses =
_sdk.cache.findAll(channelKey: channelUrl);
- return typingStatuses != null && typingStatuses.length > 0;
+ return typingStatuses != null && typingStatuses.isNotEmpty;
}
/// Returns a list of [User] who are currently typing.
diff --git a/lib/core/channel/open/open_channel.dart b/lib/core/channel/open/open_channel.dart
index 0e247007..46c7de7d 100644
--- a/lib/core/channel/open/open_channel.dart
+++ b/lib/core/channel/open/open_channel.dart
@@ -123,9 +123,7 @@ class OpenChannel extends BaseChannel {
if (params == null) {
throw InvalidParameterError();
}
- if (params.channelUrl == null) {
- params.channelUrl = channelUrl;
- }
+ params.channelUrl ??= channelUrl;
if (params.channelUrl != channelUrl) {
throw InvalidParameterError();
}
diff --git a/lib/core/message/admin_message.dart b/lib/core/message/admin_message.dart
index 8d824675..15b865bc 100644
--- a/lib/core/message/admin_message.dart
+++ b/lib/core/message/admin_message.dart
@@ -72,5 +72,6 @@ class AdminMessage extends BaseMessage {
factory AdminMessage.fromJson(Map json) =>
_$AdminMessageFromJson(json);
+ @override
Map toJson() => _$AdminMessageToJson(this);
}
diff --git a/lib/core/message/base_message.dart b/lib/core/message/base_message.dart
index 62edbd76..871ee724 100644
--- a/lib/core/message/base_message.dart
+++ b/lib/core/message/base_message.dart
@@ -88,7 +88,7 @@ class BaseMessage {
/// Gets an array of meta arrays sorted by chronological order.
/// current does not support backward compatibility
- @JsonKey(name: "sorted_metaarray")
+ @JsonKey(name: 'sorted_metaarray')
List metaArrays;
/// Custom message type
@@ -165,7 +165,7 @@ class BaseMessage {
/// Returns `true` if this message can be resend.
bool isResendable() {
- bool resendableError = errorCode == ErrorCode.connectionRequired ||
+ final resendableError = errorCode == ErrorCode.connectionRequired ||
errorCode == ErrorCode.networkError ||
errorCode == ErrorCode.ackTimeout ||
errorCode == ErrorCode.webSocketConnectionClosed ||
@@ -339,7 +339,7 @@ class BaseMessage {
static T msgFromJson(Map json,
{ChannelType channelType}) {
- String cmd = json["type"] as String;
+ final cmd = json['type'] as String;
T msg;
//basemessage backward compatibility -
if (json['custom'] != null) json['data'] = json['custom'];
@@ -386,7 +386,7 @@ class BaseMessage {
/// Map [json] object
factory BaseMessage.fromJson(Map json) {
- String cmd = json["type"] as String;
+ final cmd = json['type'] as String;
BaseMessage msg;
//basemessage backward compatibility -
if (json['custom'] != null) json['data'] = json['custom'];
diff --git a/lib/core/message/base_message_internal.dart b/lib/core/message/base_message_internal.dart
index f45e93b7..08aae18b 100644
--- a/lib/core/message/base_message_internal.dart
+++ b/lib/core/message/base_message_internal.dart
@@ -10,10 +10,9 @@ extension BaseMessageInternal on BaseMessage {
}
return mentionedUsers
- .where((element) => element.userId == user.userId)
- .toList()
- .length !=
- 0;
+ .where((element) => element.userId == user.userId)
+ .toList()
+ .isNotEmpty;
}
bool mentioned({User user, User byOtherUser}) {
@@ -35,6 +34,6 @@ extension BaseMessageInternal on BaseMessage {
}
bool hasUpdatedLaterThan(int time) {
- return this.hasCreatedLaterThan(time) && updatedAt > time;
+ return hasCreatedLaterThan(time) && updatedAt > time;
}
}
diff --git a/lib/core/message/file_message.dart b/lib/core/message/file_message.dart
index 7bf47408..51bb6879 100644
--- a/lib/core/message/file_message.dart
+++ b/lib/core/message/file_message.dart
@@ -143,6 +143,7 @@ class FileMessage extends BaseMessage {
return msg;
}
+ @override
Map toJson() => _$FileMessageToJson(this);
@override
diff --git a/lib/core/message/scheduled_user_message.dart b/lib/core/message/scheduled_user_message.dart
index c424aa2f..1ace0714 100644
--- a/lib/core/message/scheduled_user_message.dart
+++ b/lib/core/message/scheduled_user_message.dart
@@ -20,7 +20,7 @@ class ScheduledUserMessage extends BaseMessage {
final int scheduledId;
/// Scheduled message date time. (format: "YYYY-MM-DD HH:mm")
- @JsonKey(name: "scheduled_dt")
+ @JsonKey(name: 'scheduled_dt')
final String scheduledDateTimeString;
/// Scheduled message timezone. (e.g. UTC, America/Los_Angeles, etc)
@@ -40,7 +40,7 @@ class ScheduledUserMessage extends BaseMessage {
final SBError error;
/// Target languages that the message will be translated into
- @JsonKey(name: "translation_target_langs")
+ @JsonKey(name: 'translation_target_langs')
final List targetLanguages;
ScheduledUserMessage({
@@ -106,6 +106,7 @@ class ScheduledUserMessage extends BaseMessage {
factory ScheduledUserMessage.fromJson(Map json) =>
_$ScheduledUserMessageFromJson(json);
+ @override
Map toJson() => _$ScheduledUserMessageToJson(this);
@override
diff --git a/lib/core/message/user_message.dart b/lib/core/message/user_message.dart
index 89b03c5c..7708c3c4 100644
--- a/lib/core/message/user_message.dart
+++ b/lib/core/message/user_message.dart
@@ -78,6 +78,7 @@ class UserMessage extends BaseMessage {
factory UserMessage.fromJson(Map json) =>
_$UserMessageFromJson(json);
+ @override
Map toJson() => _$UserMessageToJson(this);
@override
diff --git a/lib/core/models/command.dart b/lib/core/models/command.dart
index f4bc917d..13e9be38 100644
--- a/lib/core/models/command.dart
+++ b/lib/core/models/command.dart
@@ -50,8 +50,8 @@ class Command {
this.payload,
}) {
if (payload != null) {
- this.requestId = requestId != null ? requestId : Uuid().v1();
- payload['req_id'] = this.requestId;
+ requestId = requestId ?? Uuid().v1();
+ payload['req_id'] = requestId;
payload.removeWhere((key, value) => value == null);
}
}
@@ -132,17 +132,16 @@ class Command {
UserMessageParams params,
String requestId,
) {
- Map payload = {
+ final payload = {
'channel_url': channelUrl,
'message': params.message ?? '',
'data': params.data,
'custom_type': params.customType
};
- if (params.targetLanguages?.length != 0) {
+ if (params.targetLanguages.isNotEmpty) {
payload['target_langs'] = params.targetLanguages;
- payload['translations'] = Map.fromIterable(params.targetLanguages,
- key: (e) => e, value: (e) => '');
+ payload['translations'] = {for (var e in params.targetLanguages) e: ''};
}
if (params.pushOption == PushNotificationDeliveryOption.suppress) {
@@ -174,7 +173,7 @@ class Command {
int messageId,
UserMessageParams params,
) {
- Map payload = {
+ final payload = {
'msg_id': messageId,
'channel_url': channelUrl,
'message': params.message,
@@ -194,7 +193,7 @@ class Command {
List thumbnails,
bool requireAuth,
}) {
- Map payload = {
+ final payload = {
'channel_url': channelUrl,
if (requireAuth != null) 'require_auth': requireAuth,
'url': params.uploadFile.url,
@@ -233,7 +232,7 @@ class Command {
static Command buildUpdateFileMessage(
String channelUrl, int messageId, FileMessageParams params) {
- Map payload = {
+ final payload = {
'channel_url': channelUrl,
'msg_id': messageId,
'data': params.data,
@@ -258,12 +257,13 @@ class Command {
}
String type;
- if (message is UserMessage)
+ if (message is UserMessage) {
type = CommandType.userMessageUpdate;
- else if (message is FileMessage)
+ } else if (message is FileMessage) {
type = CommandType.fileMessageUpdate;
- else
+ } else {
throw InvalidParameterError();
+ }
return Command(cmd: type, payload: {
'channel_url': message.channelUrl,
diff --git a/lib/core/models/member.dart b/lib/core/models/member.dart
index f6a9a621..303dad64 100644
--- a/lib/core/models/member.dart
+++ b/lib/core/models/member.dart
@@ -61,6 +61,7 @@ class Member extends User {
factory Member.fromJson(Map json) => _$MemberFromJson(json);
+ @override
Map toJson() => _$MemberToJson(this);
@override
diff --git a/lib/core/models/og_image.dart b/lib/core/models/og_image.dart
index a57e55fa..c71728a6 100644
--- a/lib/core/models/og_image.dart
+++ b/lib/core/models/og_image.dart
@@ -7,9 +7,11 @@ part 'og_image.g.dart';
@JsonSerializable()
class OGImage implements OGMedia, OGDisplayable {
/// Image url
+ @override
final String url;
/// Image secure url
+ @override
final String secureUrl;
/// Image type
@@ -19,9 +21,11 @@ class OGImage implements OGMedia, OGDisplayable {
final String alt;
/// Image width
+ @override
final int width;
/// Image height
+ @override
final int height;
OGImage({
diff --git a/lib/core/models/reaction.dart b/lib/core/models/reaction.dart
index 468a40c5..3589e086 100644
--- a/lib/core/models/reaction.dart
+++ b/lib/core/models/reaction.dart
@@ -21,8 +21,7 @@ class Reaction {
this.userIds,
this.updatedAt,
}) {
- updatedAts =
- Map.fromIterable(userIds, key: (e) => e, value: (e) => updatedAt);
+ updatedAts = {for (var e in userIds) e: updatedAt};
}
bool merge(ReactionEvent event) {
diff --git a/lib/core/models/reconnect_configuration.dart b/lib/core/models/reconnect_configuration.dart
index ccb8e19c..82d450a6 100644
--- a/lib/core/models/reconnect_configuration.dart
+++ b/lib/core/models/reconnect_configuration.dart
@@ -4,16 +4,16 @@ part 'reconnect_configuration.g.dart';
@JsonSerializable()
class ReconnectConfiguration {
- @JsonKey(name: "interval")
+ @JsonKey(name: 'interval')
double interval;
- @JsonKey(name: "max_interval")
+ @JsonKey(name: 'max_interval')
double maxInterval;
- @JsonKey(name: "mul")
+ @JsonKey(name: 'mul')
int multiplier;
- @JsonKey(name: "retry_cnt")
+ @JsonKey(name: 'retry_cnt')
int maximumRetryCount;
bool get enabledInfinitelyRetry => maximumRetryCount < 0;
diff --git a/lib/core/models/sender.dart b/lib/core/models/sender.dart
index 8c712c67..05f25d0e 100644
--- a/lib/core/models/sender.dart
+++ b/lib/core/models/sender.dart
@@ -47,7 +47,7 @@ class Sender extends User {
);
factory Sender.fromUser(User user, BaseChannel channel) {
- Sender sender = Sender.fromJson(user.toJson());
+ final sender = Sender.fromJson(user.toJson());
if (channel is GroupChannel) {
sender.role = channel.myRole;
} else if (channel is OpenChannel) {
@@ -66,6 +66,7 @@ class Sender extends User {
return _$SenderFromJson(json);
}
+ @override
Map toJson() => _$SenderToJson(this);
@override
diff --git a/lib/core/models/unread_count_info.dart b/lib/core/models/unread_count_info.dart
index ed5acfee..ef9bb310 100644
--- a/lib/core/models/unread_count_info.dart
+++ b/lib/core/models/unread_count_info.dart
@@ -11,7 +11,7 @@ class UnreadCountInfo {
UnreadCountInfo({this.all, this.customTypes, this.ts});
bool copyWith(UnreadCountInfo others) {
- bool didChange = false;
+ var didChange = false;
ts = others.ts;
diff --git a/lib/core/models/user.dart b/lib/core/models/user.dart
index a5e5c8c3..ded805b9 100644
--- a/lib/core/models/user.dart
+++ b/lib/core/models/user.dart
@@ -56,7 +56,7 @@ class User {
@JsonKey(defaultValue: {}, name: 'metadata')
Map metaData;
- @JsonKey(name: "require_auth_for_profile_image")
+ @JsonKey(name: 'require_auth_for_profile_image')
bool requireAuth;
String sessionToken;
@@ -130,7 +130,7 @@ class User {
factory User.fromJson(Map json) {
if (json['guest_id'] != null) json['user_id'] = json['guest_id'];
if (json['session_tokens'] != null &&
- (json['session_tokens'] as List).length > 0) {
+ (json['session_tokens'] as List).isEmpty) {
final tokens = List