Skip to content

Commit c8574fd

Browse files
authored
apply flutter_lints (#12)
* apply flutter_lints * Update readme [skip ci]
1 parent 837f2a0 commit c8574fd

36 files changed

+165
-143
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414

1515
## Download apk [here](https://nightly.link/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/workflows/flutter/master/app.zip)
1616

17+
## Flutter version: channel beta
18+
19+
```yaml
20+
environment:
21+
sdk: ">=2.14.0-0 <3.0.0"
22+
flutter: ">=2.4.0-0"
23+
```
24+
25+
```shell
26+
Flutter 2.4.0-4.2.pre • channel beta • https://github.com/flutter/flutter.git
27+
Framework • revision f18b9281c2 (4 weeks ago) • 2021-07-22 14:08:30 -0700
28+
Engine • revision 844c29f42a
29+
Tools • Dart 2.14.0 (build 2.14.0-301.2.beta)
30+
```
31+
1732
## Screenshots
1833

1934
| | | |

analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:pedantic/analysis_options.1.11.0.yaml
1+
include: package:flutter_lints/flutter.yaml
22

33
analyzer:
44
enable-experiment:

lib/app.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,31 @@ class Home extends StatelessWidget {
8989
future: getAuthState(),
9090
builder: (context, snapshot) {
9191
if (!snapshot.hasData) {
92-
print('[HOME] home [1] >> [waiting...]');
92+
debugPrint('[HOME] home [1] >> [waiting...]');
9393

9494
return Container(
9595
width: double.infinity,
9696
height: double.infinity,
9797
color: Theme.of(context).cardColor,
98-
child: Center(
98+
child: const Center(
9999
child: CircularProgressIndicator(
100-
valueColor: const AlwaysStoppedAnimation(Colors.white),
100+
valueColor: AlwaysStoppedAnimation(Colors.white),
101101
),
102102
),
103103
);
104104
}
105105

106106
if (snapshot.hasError || snapshot.data is UnauthenticatedState) {
107-
print('[HOME] home [2] >> [NotAuthenticated]');
107+
debugPrint('[HOME] home [2] >> [NotAuthenticated]');
108108
return routes[LoginPage.routeName]!(context);
109109
}
110110

111111
if (snapshot.data is AuthenticatedState) {
112-
print('[HOME] home [3] >> [Authenticated]');
112+
debugPrint('[HOME] home [3] >> [Authenticated]');
113113
return routes[HomePage.routeName]!(context);
114114
}
115115

116-
return Container(width: 0, height: 0);
116+
return const SizedBox(width: 0, height: 0);
117117
},
118118
);
119119
}

lib/data/serializers.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ part 'serializers.g.dart';
1414
UserResponse,
1515
TokenResponse,
1616
])
17-
final Serializers _serializers = _$_serializers;
18-
final serializers = (_serializers.toBuilder()
17+
final Serializers serializers = (_$serializers.toBuilder()
1918
..add(Iso8601DateTimeSerializer())
2019
..addPlugin(StandardJsonPlugin()))
2120
.build();

lib/data/serializers.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/data/user_repository_imp.dart

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:io';
22

3+
import 'package:flutter/foundation.dart';
34
import 'package:node_auth/data/exception/local_data_source_exception.dart';
45
import 'package:node_auth/data/exception/remote_data_source_exception.dart';
56
import 'package:node_auth/data/local/entities/user_and_token_entity.dart';
@@ -38,13 +39,13 @@ class UserRepositoryImpl implements UserRepository {
3839
.map(_Mappers.userAndTokenEntityToDomainAuthState)
3940
.onErrorReturn(UnauthenticatedState())
4041
.publishValue()
41-
..listen((state) => print('[USER_REPOSITORY] state=$state'))
42+
..listen((state) => debugPrint('[USER_REPOSITORY] state=$state'))
4243
..connect() {
4344
_init();
4445
}
4546

4647
@override
47-
Single_Result_Unit login({
48+
UnitResultSingle login({
4849
required String email,
4950
required String password,
5051
}) {
@@ -69,7 +70,7 @@ class UserRepositoryImpl implements UserRepository {
6970
}
7071

7172
@override
72-
Single_Result_Unit registerUser({
73+
UnitResultSingle registerUser({
7374
required String name,
7475
required String email,
7576
required String password,
@@ -78,11 +79,11 @@ class UserRepositoryImpl implements UserRepository {
7879
.asUnit();
7980

8081
@override
81-
Single_Result_Unit logout() =>
82+
UnitResultSingle logout() =>
8283
_execute<void>(() => _localDataSource.removeUserAndToken()).asUnit();
8384

8485
@override
85-
Single_Result_Unit uploadImage(File image) {
86+
UnitResultSingle uploadImage(File image) {
8687
return _userAndToken
8788
.flatMapResult((userAndToken) {
8889
if (userAndToken == null) {
@@ -118,7 +119,7 @@ class UserRepositoryImpl implements UserRepository {
118119
}
119120

120121
@override
121-
Single_Result_Unit changePassword({
122+
UnitResultSingle changePassword({
122123
required String password,
123124
required String newPassword,
124125
}) {
@@ -144,7 +145,7 @@ class UserRepositoryImpl implements UserRepository {
144145
}
145146

146147
@override
147-
Single_Result_Unit resetPassword({
148+
UnitResultSingle resetPassword({
148149
required String email,
149150
required String token,
150151
required String newPassword,
@@ -158,7 +159,7 @@ class UserRepositoryImpl implements UserRepository {
158159
).asUnit();
159160

160161
@override
161-
Single_Result_Unit sendResetPasswordEmail(String email) =>
162+
UnitResultSingle sendResetPasswordEmail(String email) =>
162163
_execute(() => _remoteDataSource.resetPassword(email)).asUnit();
163164

164165
///
@@ -185,7 +186,7 @@ class UserRepositoryImpl implements UserRepository {
185186
void _handleUnauthenticatedError(Object e, StackTrace? s) {
186187
if (e is RemoteDataSourceException &&
187188
e.statusCode == HttpStatus.unauthorized) {
188-
print(
189+
debugPrint(
189190
'[USER_REPOSITORY] {interceptor} 401 - unauthenticated error ===> login again');
190191
_localDataSource.removeUserAndToken();
191192
}
@@ -212,7 +213,7 @@ class UserRepositoryImpl implements UserRepository {
212213

213214
try {
214215
final userAndToken = await _localDataSource.userAndToken;
215-
print('$tag userAndToken local=$userAndToken');
216+
debugPrint('$tag userAndToken local=$userAndToken');
216217

217218
if (userAndToken == null) {
218219
return;
@@ -222,22 +223,22 @@ class UserRepositoryImpl implements UserRepository {
222223
userAndToken.user.email,
223224
userAndToken.token,
224225
);
225-
print('$tag userProfile server=$userProfile');
226+
debugPrint('$tag userProfile server=$userProfile');
226227
await _localDataSource.saveUserAndToken(
227228
_Mappers.userResponseToUserAndTokenEntity(
228229
userProfile,
229230
userAndToken.token,
230231
),
231232
);
232233
} on RemoteDataSourceException catch (e) {
233-
print('$tag remote error=$e');
234+
debugPrint('$tag remote error=$e');
234235

235236
if (e.statusCode == HttpStatus.unauthorized) {
236-
print('$tag 401 - unauthenticated error ===> login again');
237+
debugPrint('$tag 401 - unauthenticated error ===> login again');
237238
await _localDataSource.removeUserAndToken();
238239
}
239240
} on LocalDataSourceException catch (e) {
240-
print('$tag local error=$e');
241+
debugPrint('$tag local error=$e');
241242
await _localDataSource.removeUserAndToken();
242243
}
243244
}

lib/domain/models/auth_state.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class UnauthenticatedState
3030
Built<UnauthenticatedState, UnauthenticatedStateBuilder>,
3131
AuthenticationState {
3232
@override
33-
Null get userAndToken => null;
33+
UserAndToken? get userAndToken => null;
3434

3535
UnauthenticatedState._();
3636

lib/domain/repositories/user_repository.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ abstract class UserRepository {
88

99
Future<AuthenticationState> get authenticationState;
1010

11-
Single_Result_Unit login({
11+
UnitResultSingle login({
1212
required String email,
1313
required String password,
1414
});
1515

16-
Single_Result_Unit registerUser({
16+
UnitResultSingle registerUser({
1717
required String name,
1818
required String email,
1919
required String password,
2020
});
2121

22-
Single_Result_Unit logout();
22+
UnitResultSingle logout();
2323

24-
Single_Result_Unit uploadImage(File image);
24+
UnitResultSingle uploadImage(File image);
2525

26-
Single_Result_Unit changePassword({
26+
UnitResultSingle changePassword({
2727
required String password,
2828
required String newPassword,
2929
});
3030

31-
Single_Result_Unit resetPassword({
31+
UnitResultSingle resetPassword({
3232
required String email,
3333
required String token,
3434
required String newPassword,
3535
});
3636

37-
Single_Result_Unit sendResetPasswordEmail(String email);
37+
UnitResultSingle sendResetPasswordEmail(String email);
3838
}

lib/domain/usecases/change_password_use_case.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class ChangePasswordUseCase {
66

77
const ChangePasswordUseCase(this._userRepository);
88

9-
Single_Result_Unit call({
9+
UnitResultSingle call({
1010
required String password,
1111
required String newPassword,
1212
}) =>

lib/domain/usecases/login_use_case.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class LoginUseCase {
66

77
const LoginUseCase(this._userRepository);
88

9-
Single_Result_Unit call({
9+
UnitResultSingle call({
1010
required String email,
1111
required String password,
1212
}) =>

0 commit comments

Comments
 (0)