chore(repo): fix lints

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2021-10-01 16:45:16 +05:30
committed by xsahil03x
parent 6e48f9754d
commit ca7cf541a7
76 changed files with 1004 additions and 969 deletions
@@ -75,7 +75,7 @@ class ChannelApi {
if (messageLimit != null) 'message_limit': messageLimit,
// pagination
...paginationParams.toJson()
...paginationParams.toJson(),
}),
},
);
@@ -7,7 +7,7 @@ enum PushProvider {
firebase,
/// Send notifications using Apple's Push Notification service
apn
apn,
}
/// Helper extension for [PushProvider]
@@ -90,7 +90,7 @@ enum ChatErrorCode {
internalSystemError,
/// No access to requested channels
noAccessToChannels
noAccessToChannels,
}
const _errorCodeWithDescription = {
@@ -98,14 +98,20 @@ const _errorCodeWithDescription = {
MapEntry(1000, 'Unauthorised, token not defined'),
ChatErrorCode.inputError:
MapEntry(4, 'Wrong data/parameter is sent to the API'),
ChatErrorCode.duplicateUsername: MapEntry(6,
'Duplicate username is sent while enforce_unique_usernames is enabled'),
ChatErrorCode.duplicateUsername: MapEntry(
6,
'Duplicate username is sent while enforce_unique_usernames is enabled',
),
ChatErrorCode.messageTooLong: MapEntry(20, 'Message is too long'),
ChatErrorCode.eventNotSupported: MapEntry(18, 'Event is not supported'),
ChatErrorCode.channelFeatureNotSupported: MapEntry(19,
'The feature is currently disabled on the dashboard (i.e. Reactions & Replies)'),
ChatErrorCode.multipleNestling: MapEntry(21,
'Multiple Levels Reply is not supported - the API only supports 1 level deep reply threads'),
ChatErrorCode.channelFeatureNotSupported: MapEntry(
19,
'The feature is currently disabled on the dashboard (i.e. Reactions & Replies)',
),
ChatErrorCode.multipleNestling: MapEntry(
21,
'Multiple Levels Reply is not supported - the API only supports 1 level deep reply threads',
),
ChatErrorCode.customCommandEndpointCall:
MapEntry(45, 'Custom Command handler returned an error'),
ChatErrorCode.customCommandEndpointMissing:
@@ -35,7 +35,8 @@ class StreamWebSocketError extends StreamChatError {
///
factory StreamWebSocketError.fromWebSocketChannelError(
WebSocketChannelException error) {
WebSocketChannelException error,
) {
final message = error.message ?? '';
return StreamWebSocketError(message);
}
@@ -105,8 +105,11 @@ class LoggingInterceptor extends Interceptor {
final formDataMap = <String, dynamic>{}
..addEntries(data.fields)
..addEntries(data.files);
_printMapAsTable(_logPrintRequest, formDataMap,
header: 'Form data | ${data.boundary}');
_printMapAsTable(
_logPrintRequest,
formDataMap,
header: 'Form data | ${data.boundary}',
);
} else {
_printBlock(_logPrintRequest, data.toString());
}
@@ -201,14 +204,19 @@ class LoggingInterceptor extends Interceptor {
}
void _printRequestHeader(
void Function(Object) logPrint, RequestOptions options) {
void Function(Object) logPrint,
RequestOptions options,
) {
final uri = options.uri;
final method = options.method;
_printBoxed(logPrint, header: 'Request ║ $method ', text: uri.toString());
}
void _printLine(void Function(Object) logPrint,
[String pre = '', String suf = '']) =>
void _printLine(
void Function(Object) logPrint, [
String pre = '',
String suf = '',
]) =>
logPrint('$pre${'' * maxWidth}$suf');
void _printKV(void Function(Object) logPrint, String? key, Object? v) {
@@ -227,8 +235,10 @@ class LoggingInterceptor extends Interceptor {
final lines = (msg.length / maxWidth).ceil();
for (var i = 0; i < lines; ++i) {
logPrint((i >= 0 ? '' : '') +
msg.substring(i * maxWidth,
math.min<int>(i * maxWidth + maxWidth, msg.length)));
msg.substring(
i * maxWidth,
math.min<int>(i * maxWidth + maxWidth, msg.length),
));
}
}
@@ -301,8 +311,13 @@ class LoggingInterceptor extends Interceptor {
if (compact) {
logPrint('${_indent(tabs)} $e${!isLast ? ',' : ''}');
} else {
_printPrettyMap(logPrint, e,
tabs: tabs + 1, isListItem: true, isLast: isLast);
_printPrettyMap(
logPrint,
e,
tabs: tabs + 1,
isListItem: true,
isLast: isLast,
);
}
} else {
logPrint('${_indent(tabs + 2)} $e${isLast ? '' : ','}');
@@ -56,12 +56,15 @@ class Attachment extends Equatable {
/// Create a new instance from a json
factory Attachment.fromJson(Map<String, dynamic> json) =>
_$AttachmentFromJson(
Serializer.moveToExtraDataFromRoot(json, topLevelFields));
Serializer.moveToExtraDataFromRoot(json, topLevelFields),
);
/// Create a new instance from a db data
factory Attachment.fromData(Map<String, dynamic> json) =>
_$AttachmentFromJson(Serializer.moveToExtraDataFromRoot(
json, topLevelFields + dbSpecificTopLevelFields));
json,
topLevelFields + dbSpecificTopLevelFields,
));
///The attachment type based on the URL resource. This can be: audio,
///image or video
@@ -11,54 +11,6 @@ part 'attachment_file.freezed.dart';
part 'attachment_file.g.dart';
/// Union class to hold various [UploadState] of a attachment.
@freezed
class UploadState with _$UploadState {
/// Preparing state of the union
const factory UploadState.preparing() = Preparing;
/// InProgress state of the union
const factory UploadState.inProgress({
required int uploaded,
required int total,
}) = InProgress;
/// Success state of the union
const factory UploadState.success() = Success;
/// Failed state of the union
const factory UploadState.failed({required String error}) = Failed;
/// Creates a new instance from a json
factory UploadState.fromJson(Map<String, dynamic> json) =>
_$UploadStateFromJson(json);
}
/// Helper extension for UploadState
extension UploadStateX on UploadState? {
/// Returns true if state is [Preparing]
bool get isPreparing => this is Preparing;
/// Returns true if state is [InProgress]
bool get isInProgress => this is InProgress;
/// Returns true if state is [Success]
bool get isSuccess => this is Success;
/// Returns true if state is [Failed]
bool get isFailed => this is Failed;
}
Uint8List? _fromString(String? bytes) {
if (bytes == null) return null;
return Uint8List.fromList(bytes.codeUnits);
}
String? _toString(Uint8List? bytes) {
if (bytes == null) return null;
return String.fromCharCodes(bytes);
}
/// The class that contains the information about an attachment file
@JsonSerializable()
class AttachmentFile {
@@ -135,3 +87,51 @@ class AttachmentFile {
return multiPartFile;
}
}
/// Union class to hold various [UploadState] of a attachment.
@freezed
class UploadState with _$UploadState {
/// Preparing state of the union
const factory UploadState.preparing() = Preparing;
/// InProgress state of the union
const factory UploadState.inProgress({
required int uploaded,
required int total,
}) = InProgress;
/// Success state of the union
const factory UploadState.success() = Success;
/// Failed state of the union
const factory UploadState.failed({required String error}) = Failed;
/// Creates a new instance from a json
factory UploadState.fromJson(Map<String, dynamic> json) =>
_$UploadStateFromJson(json);
}
/// Helper extension for UploadState
extension UploadStateX on UploadState? {
/// Returns true if state is [Preparing]
bool get isPreparing => this is Preparing;
/// Returns true if state is [InProgress]
bool get isInProgress => this is InProgress;
/// Returns true if state is [Success]
bool get isSuccess => this is Success;
/// Returns true if state is [Failed]
bool get isFailed => this is Failed;
}
Uint8List? _fromString(String? bytes) {
if (bytes == null) return null;
return Uint8List.fromList(bytes.codeUnits);
}
String? _toString(Uint8List? bytes) {
if (bytes == null) return null;
return String.fromCharCodes(bytes);
}
@@ -38,7 +38,8 @@ class ChannelModel {
/// Create a new instance from a json
factory ChannelModel.fromJson(Map<String, dynamic> json) =>
_$ChannelModelFromJson(
Serializer.moveToExtraDataFromRoot(json, topLevelFields));
Serializer.moveToExtraDataFromRoot(json, topLevelFields),
);
/// The id of this channel
final String id;
@@ -81,7 +81,8 @@ class Message extends Equatable {
/// Create a new instance from a json
factory Message.fromJson(Map<String, dynamic> json) => _$MessageFromJson(
Serializer.moveToExtraDataFromRoot(json, topLevelFields));
Serializer.moveToExtraDataFromRoot(json, topLevelFields),
);
/// The message ID. This is either created by Stream or set client side when
/// the message is added.
@@ -48,7 +48,8 @@ class OwnUser extends User {
/// Create a new instance from json.
factory OwnUser.fromJson(Map<String, dynamic> json) => _$OwnUserFromJson(
Serializer.moveToExtraDataFromRoot(json, topLevelFields));
Serializer.moveToExtraDataFromRoot(json, topLevelFields),
);
/// Create a new instance from [User] object.
factory OwnUser.fromUser(User user) => OwnUser(
@@ -118,12 +118,18 @@ class User extends Equatable {
/// True if user is online.
@JsonKey(
includeIfNull: false, toJson: Serializer.readOnly, defaultValue: false)
includeIfNull: false,
toJson: Serializer.readOnly,
defaultValue: false,
)
final bool online;
/// True if user is banned from the chat.
@JsonKey(
includeIfNull: false, toJson: Serializer.readOnly, defaultValue: false)
includeIfNull: false,
toJson: Serializer.readOnly,
defaultValue: false,
)
final bool banned;
/// Map of custom user extraData.