Skip to content

Commit 1db8b56

Browse files
committed
🎨 Formatted to 80 line length
1 parent a2d6e74 commit 1db8b56

File tree

7 files changed

+58
-26
lines changed

7 files changed

+58
-26
lines changed

lib/chopper/json_serializable_converter.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,20 @@ class JsonSerializableConverter extends JsonConverter {
2626
T _decodeMap<T>(Map<String, dynamic> values) {
2727
final jsonFactory = factories[T];
2828
if (jsonFactory == null) {
29-
throw JsonUnsupportedObjectError(T, cause: 'No fromJson was registered for JsonSerializableConverter for $T');
29+
throw JsonUnsupportedObjectError(T,
30+
cause:
31+
'No fromJson was registered for JsonSerializableConverter for $T');
3032
}
3133
if (jsonFactory is! JsonFactory<T>) {
32-
throw JsonUnsupportedObjectError(T, cause: 'fromJson type does not match $T');
34+
throw JsonUnsupportedObjectError(T,
35+
cause: 'fromJson type does not match $T');
3336
}
3437

3538
return jsonFactory(values);
3639
}
3740

38-
List<T> _decodeList<T>(Iterable<dynamic> values) => values.whereNotNull().map<T>((v) => _decode<T>(v) as T).toList();
41+
List<T> _decodeList<T>(Iterable<dynamic> values) =>
42+
values.whereNotNull().map<T>((v) => _decode<T>(v) as T).toList();
3943

4044
dynamic _decode<T>(dynamic entity) {
4145
if (entity is Iterable) return _decodeList<T>(entity as List);
@@ -51,6 +55,7 @@ class JsonSerializableConverter extends JsonConverter {
5155
) async {
5256
final jsonRes = await super.convertResponse<dynamic, dynamic>(response);
5357

54-
return jsonRes.copyWith<BodyType>(body: _decode<InnerType>(jsonRes.body) as BodyType);
58+
return jsonRes.copyWith<BodyType>(
59+
body: _decode<InnerType>(jsonRes.body) as BodyType);
5560
}
5661
}

lib/common/dcc_logger.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class DCCLogger {
1414
String? tag,
1515
Logger? logger,
1616
]) {
17-
_logger = logger ?? Logger('${name ?? 'DCC'}${tag != null ? ' ($tag)' : ''}');
17+
_logger =
18+
logger ?? Logger('${name ?? 'DCC'}${tag != null ? ' ($tag)' : ''}');
1819
final rootLogger = Logger.root;
1920
rootLogger.onRecord.listen((event) {
2021
if (kDebugMode) {
@@ -26,21 +27,28 @@ class DCCLogger {
2627
static void _prettyPrinter(LogRecord record) {
2728
final error = record.error;
2829
final stacktrace = record.stackTrace;
29-
final message = record.object is DCCLogRecord ? record.object.toString() : record.message;
30+
final message = record.object is DCCLogRecord
31+
? record.object.toString()
32+
: record.message;
3033

3134
debugPrint(_formatLogPrint(record, message));
32-
if (error != null) debugPrint(_formatLogPrint(record, '${error.runtimeType}: $error'));
35+
if (error != null)
36+
debugPrint(_formatLogPrint(record, '${error.runtimeType}: $error'));
3337
if (stacktrace != null) {
34-
final lines = stacktrace.toString().split('\n').where((e) => e.isNotEmpty);
38+
final lines =
39+
stacktrace.toString().split('\n').where((e) => e.isNotEmpty);
3540
for (final line in lines) {
3641
debugPrint(_formatLogPrint(record, line));
3742
}
3843
}
3944
}
4045

4146
static String _formatLogPrint(LogRecord record, String message) {
42-
final logMessage = '[${_formatter.format(record.time)}] [${record.level.name}] ${record.loggerName}: $message';
43-
return record.level == Level.SEVERE ? _addWarningColor(logMessage) : logMessage;
47+
final logMessage =
48+
'[${_formatter.format(record.time)}] [${record.level.name}] ${record.loggerName}: $message';
49+
return record.level == Level.SEVERE
50+
? _addWarningColor(logMessage)
51+
: logMessage;
4452
}
4553

4654
static String _addWarningColor(String message) {

lib/common/extensions/build_context.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
44
extension ThemingExtensions on BuildContext {
55
/// Get [ThemeData] from [BuildContext].
66
ThemeData get theme => Theme.of(this);
7+
78
/// Get Theme [ColorScheme] from [BuildContext].
89
ColorScheme get colors => theme.colorScheme;
910

lib/common/result/result.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ final class Success<T> extends Result<T> {
6767

6868
@override
6969
bool operator ==(Object other) {
70-
return identical(this, other) || other is Success<T> && runtimeType == other.runtimeType && value == other.value;
70+
return identical(this, other) ||
71+
other is Success<T> &&
72+
runtimeType == other.runtimeType &&
73+
value == other.value;
7174
}
7275

7376
@override
@@ -86,7 +89,9 @@ final class Failure<T> extends Result<T> {
8689
@override
8790
bool operator ==(Object other) {
8891
return identical(this, other) ||
89-
other is Failure<T> && runtimeType == other.runtimeType && other.exception == exception;
92+
other is Failure<T> &&
93+
runtimeType == other.runtimeType &&
94+
other.exception == exception;
9095
}
9196

9297
@override
@@ -101,7 +106,8 @@ final class Loading<T> extends Result<T> {
101106

102107
@override
103108
bool operator ==(Object other) {
104-
return identical(this, other) || other is Loading<T> && runtimeType == other.runtimeType;
109+
return identical(this, other) ||
110+
other is Loading<T> && runtimeType == other.runtimeType;
105111
}
106112

107113
@override

test/chopper/datetime_converter_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void main() {
1313

1414
test('HHmm tests', () {
1515
const converter = DateTimeConverter.HHmm();
16-
final date = DateTime(1970, 1, 1, 10,30);
16+
final date = DateTime(1970, 1, 1, 10, 30);
1717
const dateString = '10:30';
1818

1919
expect(converter.toJson(date), dateString);

test/chopper/json_serializable_converter_test.dart

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,41 @@ void main() {
1313

1414
const converter = JsonSerializableConverter({});
1515

16-
expect(() => converter.convertResponse<TestModel, TestModel>(response), throwsA(isA<JsonUnsupportedObjectError>()));
16+
expect(() => converter.convertResponse<TestModel, TestModel>(response),
17+
throwsA(isA<JsonUnsupportedObjectError>()));
1718
});
1819

1920
test('Error is thrown when wrong factory is added', () {
2021
final response = Response(baseResponse, '{"name":"John"}');
2122

22-
const converter = JsonSerializableConverter({TestModel: TestModel2.fromJson});
23+
const converter =
24+
JsonSerializableConverter({TestModel: TestModel2.fromJson});
2325

24-
expect(() => converter.convertResponse<TestModel, TestModel>(response), throwsA(isA<JsonUnsupportedObjectError>()));
26+
expect(() => converter.convertResponse<TestModel, TestModel>(response),
27+
throwsA(isA<JsonUnsupportedObjectError>()));
2528
});
2629

2730
test('Uses model to convert json into model', () async {
2831
final response = Response(baseResponse, '{"name":"John"}');
2932

30-
const converter = JsonSerializableConverter({TestModel: TestModel.fromJson});
33+
const converter =
34+
JsonSerializableConverter({TestModel: TestModel.fromJson});
3135

32-
final result = await converter.convertResponse<TestModel, TestModel>(response);
36+
final result =
37+
await converter.convertResponse<TestModel, TestModel>(response);
3338

3439
expect(result.body?.name, 'John');
3540
});
3641

3742
test('Uses model to convert json into List<model>', () async {
38-
final response = Response(baseResponse, '[{"name":"John"},{"name":"John2"}]');
43+
final response =
44+
Response(baseResponse, '[{"name":"John"},{"name":"John2"}]');
3945

40-
const converter = JsonSerializableConverter({TestModel: TestModel.fromJson});
46+
const converter =
47+
JsonSerializableConverter({TestModel: TestModel.fromJson});
4148

42-
final result = await converter.convertResponse<List<TestModel>, TestModel>(response);
49+
final result =
50+
await converter.convertResponse<List<TestModel>, TestModel>(response);
4351

4452
expect(result.body?[0].name, 'John');
4553
expect(result.body?[1].name, 'John2');
@@ -49,7 +57,8 @@ void main() {
4957
class TestModel {
5058
TestModel(this.name);
5159

52-
factory TestModel.fromJson(Map<String, dynamic> json) => TestModel(json['name'] as String);
60+
factory TestModel.fromJson(Map<String, dynamic> json) =>
61+
TestModel(json['name'] as String);
5362

5463
final String name;
5564

@@ -59,7 +68,8 @@ class TestModel {
5968
class TestModel2 {
6069
TestModel2(this.name);
6170

62-
factory TestModel2.fromJson(Map<String, dynamic> json) => TestModel2(json['name'] as String);
71+
factory TestModel2.fromJson(Map<String, dynamic> json) =>
72+
TestModel2(json['name'] as String);
6373

6474
final String name;
6575

test/dcc_logger_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ class MockLogger extends Mock implements Logger {}
88
void main() {
99
group('uninitialised tests', () {
1010
test('throws assertion error when logger is not initialised', () {
11-
expect(() => DCCLogger.info('test message'), throwsA(isA<AssertionError>()));
12-
expect(() => DCCLogger.severe('test message'), throwsA(isA<AssertionError>()));
11+
expect(
12+
() => DCCLogger.info('test message'), throwsA(isA<AssertionError>()));
13+
expect(() => DCCLogger.severe('test message'),
14+
throwsA(isA<AssertionError>()));
1315
});
1416
});
1517

0 commit comments

Comments
 (0)