Skip to content

Commit 6fea28c

Browse files
committed
🎨 Reformatted code
1 parent cbc86d7 commit 6fea28c

36 files changed

+356
-660
lines changed

analysis_options.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
include: package:very_good_analysis/analysis_options.yaml
22

3+
formatter:
4+
page_width: 120
5+
36
linter:
47
rules:
58
lines_longer_than_80_chars: false
9+
require_trailing_commas: false
610
analyzer:
711
errors:
812
missing_return: error

example/lib/core/modules/chopper_module.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ import 'package:injectable/injectable.dart';
99
abstract class ChopperModule {
1010
@lazySingleton
1111
ChopperClient chopper() => ChopperClient(
12-
converter: const JsonSerializableConverter(_factories),
13-
interceptors: [
14-
// We want to disable logging in release mode because it could leak sensitive information
15-
if (kDebugMode) ...[
16-
HttpLoggingInterceptor(),
17-
],
18-
],
19-
);
12+
converter: const JsonSerializableConverter(_factories),
13+
interceptors: [
14+
// We want to disable logging in release mode because it could leak sensitive information
15+
if (kDebugMode) ...[HttpLoggingInterceptor()],
16+
],
17+
);
2018
}
2119

2220
const _factories = {

example/lib/main.dart

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,31 @@ class MyHomePage extends StatelessWidget {
3434
child: Column(
3535
children: [
3636
ElevatedButton(
37-
onPressed: () => Navigator.of(context).push(
38-
MaterialPageRoute(
39-
builder: (context) => UserPage(
40-
onCreateCubit: (context) =>
41-
getIt<UserCubit>()..getRandomUser(),
37+
onPressed:
38+
() => Navigator.of(context).push(
39+
MaterialPageRoute(
40+
builder:
41+
(context) => UserPage(
42+
onCreateCubit:
43+
(context) =>
44+
getIt<UserCubit>()..getRandomUser(),
45+
),
46+
),
4247
),
43-
),
44-
),
4548
child: const Text('Get user succesfully'),
4649
),
4750
ElevatedButton(
48-
onPressed: () => Navigator.of(context).push(
49-
MaterialPageRoute(
50-
builder: (context) => UserPage(
51-
onCreateCubit: (context) =>
52-
getIt<UserCubit>()..getRandomUserFails(),
51+
onPressed:
52+
() => Navigator.of(context).push(
53+
MaterialPageRoute(
54+
builder:
55+
(context) => UserPage(
56+
onCreateCubit:
57+
(context) =>
58+
getIt<UserCubit>()..getRandomUserFails(),
59+
),
60+
),
5361
),
54-
),
55-
),
5662
child: const Text('Get user fails'),
5763
),
5864
],

example/lib/profile/data/model/api_user_response.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ part 'api_user_response.g.dart';
77

88
@freezed
99
sealed class ApiUserResponse with _$ApiUserResponse {
10-
const factory ApiUserResponse({
11-
required List<User> results,
12-
}) = _ApiUserResponse;
10+
const factory ApiUserResponse({required List<User> results}) =
11+
_ApiUserResponse;
1312

1413
factory ApiUserResponse.fromJson(Map<String, dynamic> json) =>
1514
_$ApiUserResponseFromJson(json);

example/lib/profile/data/model/street.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ part 'street.g.dart';
55

66
@freezed
77
sealed class Street with _$Street {
8-
const factory Street({
9-
required int number,
10-
required String name,
11-
}) = _Street;
8+
const factory Street({required int number, required String name}) = _Street;
129

1310
factory Street.fromJson(Map<String, dynamic> json) => _$StreetFromJson(json);
1411
}

example/lib/profile/presentation/cubit/user_state.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ part of 'user_cubit.dart';
22

33
@freezed
44
sealed class UserState with _$UserState {
5-
const factory UserState({
6-
User? user,
7-
}) = _UserState;
5+
const factory UserState({User? user}) = _UserState;
86
}

example/lib/profile/presentation/user_page.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,30 @@ import 'package:flutter/material.dart';
55

66
class UserPage extends BlocfulWidget<UserCubit, UserState, UserEvent> {
77
const UserPage({required this.onCreateCubit, super.key})
8-
: super(onCreateBloc: onCreateCubit);
8+
: super(onCreateBloc: onCreateCubit);
99

1010
final UserCubit Function(BuildContext)? onCreateCubit;
1111

1212
@override
1313
void onPresentationEvent(BuildContext context, UserEvent event) {
14-
ScaffoldMessenger.of(context)
15-
.showSnackBar(SnackBar(content: Text(event.reason)));
14+
ScaffoldMessenger.of(
15+
context,
16+
).showSnackBar(SnackBar(content: Text(event.reason)));
1617
}
1718

1819
@override
1920
Widget builder(BuildContext context, UserCubit bloc, UserState state) {
2021
return Scaffold(
2122
body: SafeArea(
2223
child: Center(
23-
child: Column(
24-
mainAxisAlignment: MainAxisAlignment.center,
25-
children: [
26-
Text(state.user?.email ?? ''),
27-
Text(state.user?.phone ?? ''),
28-
],
29-
)),
24+
child: Column(
25+
mainAxisAlignment: MainAxisAlignment.center,
26+
children: [
27+
Text(state.user?.email ?? ''),
28+
Text(state.user?.phone ?? ''),
29+
],
30+
),
31+
),
3032
),
3133
);
3234
}

lib/chopper/color_converter.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'dart:ui';
22

33
import 'package:json_annotation/json_annotation.dart';
44

5-
65
/// A class that implements JsonConverter to convert Color objects to and from JSON.
76
class ColorConverter implements JsonConverter<Color, String> {
87
/// A class that implements JsonConverter to convert Color objects to and from JSON.

lib/chopper/datetime_converter.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'package:json_annotation/json_annotation.dart';
33

44
enum _DateFormats {
55
yyyyMMdd,
6-
// Name contains the exact pattern for date formatting.
7-
//ignore: constant_identifier_names
6+
// Name contains the exact pattern for date formatting.
7+
//ignore: constant_identifier_names
88
HHmm,
99
}
1010

lib/chopper/json_serializable_converter.dart

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,16 @@ class JsonSerializableConverter extends JsonConverter {
2626
T _decodeMap<T>(Map<String, dynamic> values) {
2727
final jsonFactory = factories[T];
2828
if (jsonFactory == null) {
29-
throw JsonUnsupportedObjectError(
30-
T,
31-
cause:
32-
'No fromJson was registered for JsonSerializableConverter for $T',
33-
);
29+
throw JsonUnsupportedObjectError(T, cause: 'No fromJson was registered for JsonSerializableConverter for $T');
3430
}
3531
if (jsonFactory is! JsonFactory<T>) {
36-
throw JsonUnsupportedObjectError(
37-
T,
38-
cause: 'fromJson type does not match $T',
39-
);
32+
throw JsonUnsupportedObjectError(T, cause: 'fromJson type does not match $T');
4033
}
4134

4235
return jsonFactory(values);
4336
}
4437

45-
List<T> _decodeList<T>(Iterable<dynamic> values) =>
46-
values.nonNulls.map<T>((v) => _decode<T>(v) as T).toList();
38+
List<T> _decodeList<T>(Iterable<dynamic> values) => values.nonNulls.map<T>((v) => _decode<T>(v) as T).toList();
4739

4840
dynamic _decode<T>(dynamic entity) {
4941
if (entity is Iterable) return _decodeList<T>(entity as List);
@@ -54,13 +46,9 @@ class JsonSerializableConverter extends JsonConverter {
5446
}
5547

5648
@override
57-
FutureOr<Response<BodyType>> convertResponse<BodyType, InnerType>(
58-
Response<dynamic> response,
59-
) async {
49+
FutureOr<Response<BodyType>> convertResponse<BodyType, InnerType>(Response<dynamic> response) async {
6050
final jsonRes = await super.convertResponse<dynamic, dynamic>(response);
6151

62-
return jsonRes.copyWith<BodyType>(
63-
body: _decode<InnerType>(jsonRes.body) as BodyType,
64-
);
52+
return jsonRes.copyWith<BodyType>(body: _decode<InnerType>(jsonRes.body) as BodyType);
6553
}
6654
}

0 commit comments

Comments
 (0)