Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 0478ff9

Browse files
author
Stijn Mommersteeg
committed
Fixed static analysis for full pub score
1 parent 17b7be4 commit 0478ff9

17 files changed

+245
-195
lines changed

lib/pin_lock.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ export 'package:pin_lock/src/repositories/pin_repository.dart';
2727
export 'package:pin_lock/src/repositories/pin_repository_impl.dart';
2828

2929
class PinLock {
30+
PinLock._();
3031
static const MethodChannel _channel = MethodChannel('pin_lock');
3132

32-
static void setHideAppContent(bool preference, {String? iosAssetImage}) {
33+
static void setHideAppContent({
34+
required bool preference,
35+
String? iosAssetImage,
36+
}) {
3337
_channel.invokeMethod(
3438
'setHideAppContent',
3539
{'shouldHide': preference, 'iosAsset': iosAssetImage},
@@ -60,7 +64,8 @@ class PinLock {
6064
static Future<Authenticator> baseAuthenticator(String userId) async =>
6165
PinLock.authenticatorInstance(
6266
repository: LocalAuthenticationRepositoryImpl(
63-
await SharedPreferences.getInstance()),
67+
await SharedPreferences.getInstance(),
68+
),
6469
biometricAuthenticator: LocalAuthentication(),
6570
lockController: LockController(),
6671
userId: UserId(userId),

lib/src/blocs/cubit/lock_cubit.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ class LockCubit extends Cubit<LockScreenState> {
2222

2323
Future<void> unlockWithBiometrics(String userFacingExplanation) async {
2424
final result = await _authenticator.unlockWithBiometrics(
25-
userFacingExplanation: userFacingExplanation);
25+
userFacingExplanation: userFacingExplanation,
26+
);
2627
result.fold(
27-
(l) => emit(LockScreenState(pin: state.pin, error: l)), (r) => null);
28+
(l) => emit(LockScreenState(pin: state.pin, error: l)),
29+
(r) => null,
30+
);
2831
}
2932
}
3033

lib/src/blocs/cubit/setup_local_auth_cubit.dart

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,46 @@ class SetuplocalauthCubit extends Cubit<SetupStage> {
1313
final lastState = state;
1414
if (lastState is Base) {
1515
final isPinAuthEnabled = await authenticator.isPinAuthenticationEnabled();
16-
emit(lastState.copyWith(
17-
isPinAuthEnabled: isPinAuthEnabled, isLoading: false));
16+
emit(
17+
lastState.copyWith(
18+
isPinAuthEnabled: isPinAuthEnabled,
19+
isLoading: false,
20+
),
21+
);
1822

1923
if (!isPinAuthEnabled) {
20-
emit(lastState.copyWith(
21-
isBiometricAuthAvailable: false,
22-
isBiometricAuthEnabled: false,
23-
isLoading: false,
24-
isPinAuthEnabled: isPinAuthEnabled,
25-
));
24+
emit(
25+
lastState.copyWith(
26+
isBiometricAuthAvailable: false,
27+
isBiometricAuthEnabled: false,
28+
isLoading: false,
29+
isPinAuthEnabled: isPinAuthEnabled,
30+
),
31+
);
2632
return;
2733
}
2834

2935
final biometrics =
3036
await authenticator.getBiometricAuthenticationAvailability();
3137
if (biometrics is Available) {
32-
emit(lastState.copyWith(
33-
isPinAuthEnabled: isPinAuthEnabled,
34-
isBiometricAuthAvailable: true,
35-
isBiometricAuthEnabled: biometrics.isEnabled,
36-
isLoading: false,
37-
));
38+
emit(
39+
lastState.copyWith(
40+
isPinAuthEnabled: isPinAuthEnabled,
41+
isBiometricAuthAvailable: true,
42+
isBiometricAuthEnabled: biometrics.isEnabled,
43+
isLoading: false,
44+
),
45+
);
3846
}
3947
if (biometrics is Unavailable) {
40-
emit(lastState.copyWith(
41-
isPinAuthEnabled: isPinAuthEnabled,
42-
isBiometricAuthEnabled: false,
43-
isBiometricAuthAvailable: false,
44-
isLoading: false,
45-
));
48+
emit(
49+
lastState.copyWith(
50+
isPinAuthEnabled: isPinAuthEnabled,
51+
isBiometricAuthEnabled: false,
52+
isBiometricAuthAvailable: false,
53+
isLoading: false,
54+
),
55+
);
4656
}
4757
} else {
4858
emit(const Base(isLoading: true));
@@ -59,8 +69,10 @@ class SetuplocalauthCubit extends Cubit<SetupStage> {
5969
final result = biometricAvailability.isEnabled
6070
? await authenticator.disableBiometricAuthentication()
6171
: await authenticator.enableBiometricAuthentication();
62-
result.fold((l) => emit(lastState.copyWith(error: l)),
63-
(r) => checkInitialState());
72+
result.fold(
73+
(l) => emit(lastState.copyWith(error: l)),
74+
(r) => checkInitialState(),
75+
);
6476
}
6577
}
6678
}
@@ -122,7 +134,8 @@ class SetuplocalauthCubit extends Cubit<SetupStage> {
122134
final lastState = state;
123135
if (lastState is Disabling) {
124136
final result = await authenticator.disableAuthenticationWithPin(
125-
pin: Pin(lastState.pin));
137+
pin: Pin(lastState.pin),
138+
);
126139
result.fold(
127140
(l) => emit(lastState.copyWith(pin: '', error: l)),
128141
(r) => checkInitialState(),
@@ -173,11 +186,13 @@ class SetuplocalauthCubit extends Cubit<SetupStage> {
173186
emit(lastState.copyWith(currentPin: '', error: l));
174187
break;
175188
case LocalAuthFailure.pinNotMatching:
176-
emit(lastState.copyWith(
177-
newPin: '',
178-
confirmationPin: '',
179-
error: l,
180-
));
189+
emit(
190+
lastState.copyWith(
191+
newPin: '',
192+
confirmationPin: '',
193+
error: l,
194+
),
195+
);
181196
break;
182197
default:
183198
emit(lastState.copyWith(error: l));

lib/src/entities/authenticator.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ abstract class Authenticator with WidgetsBindingObserver {
4343

4444
/// Disables locking the app completely, including biometric authentication
4545
/// Only happens if provided [pin] is correct, or if [force] is true (which should be avoided)
46-
Future<Either<LocalAuthFailure, Unit>> disableAuthenticationWithPin(
47-
{required Pin pin, bool force = false});
46+
Future<Either<LocalAuthFailure, Unit>> disableAuthenticationWithPin({
47+
required Pin pin,
48+
bool force = false,
49+
});
4850

4951
/// Disables biometric authentication. If [requirePin] is true, it is necessary to provide the correct [pin]
5052
/// before biometric authentication is disabled
@@ -74,8 +76,9 @@ abstract class Authenticator with WidgetsBindingObserver {
7476
Future<bool> isPinAuthenticationEnabled();
7577

7678
/// Triggers the OS's biometric authentication and changes the [lockState] if successful
77-
Future<Either<LocalAuthFailure, Unit>> unlockWithBiometrics(
78-
{required String userFacingExplanation});
79+
Future<Either<LocalAuthFailure, Unit>> unlockWithBiometrics({
80+
required String userFacingExplanation,
81+
});
7982

8083
/// Make an attempt to unlock the app using provided [pin]. If the [pin] is correct,
8184
/// [lockState] will be changed and lock screen dismissed

lib/src/entities/authenticator_impl.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
7373
if (now.millisecondsSinceEpoch - lastActive.millisecondsSinceEpoch >
7474
lockAfterDuration.inMilliseconds) {
7575
_lockController.lock(
76-
availableMethods: await getAvailableBiometricMethods());
76+
availableMethods: await getAvailableBiometricMethods(),
77+
);
7778
}
7879
}
7980
break;
@@ -127,8 +128,10 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
127128
}
128129

129130
@override
130-
Future<Either<LocalAuthFailure, Unit>> disableAuthenticationWithPin(
131-
{required Pin pin, bool force = false}) async {
131+
Future<Either<LocalAuthFailure, Unit>> disableAuthenticationWithPin({
132+
required Pin pin,
133+
bool force = false,
134+
}) async {
132135
if (!force) {
133136
final isAuthenticationEnabled = await isPinAuthenticationEnabled();
134137
if (!isAuthenticationEnabled) {
@@ -233,8 +236,9 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
233236
/// -- Usage --
234237
235238
@override
236-
Future<Either<LocalAuthFailure, Unit>> unlockWithPin(
237-
{required Pin pin}) async {
239+
Future<Either<LocalAuthFailure, Unit>> unlockWithPin({
240+
required Pin pin,
241+
}) async {
238242
final isEnabled = await isPinAuthenticationEnabled();
239243
if (!isEnabled) {
240244
_lockController.unlock();
@@ -256,8 +260,9 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
256260
}
257261

258262
@override
259-
Future<Either<LocalAuthFailure, Unit>> unlockWithBiometrics(
260-
{required String userFacingExplanation}) async {
263+
Future<Either<LocalAuthFailure, Unit>> unlockWithBiometrics({
264+
required String userFacingExplanation,
265+
}) async {
261266
final biometricAvailability =
262267
await getBiometricAuthenticationAvailability();
263268
if (biometricAvailability is Available) {

lib/src/presentation/authenticator_widget.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ import 'package:flutter/material.dart';
44
import 'package:flutter_bloc/flutter_bloc.dart';
55
import 'package:pin_lock/pin_lock.dart';
66
import 'package:pin_lock/src/blocs/cubit/lock_cubit.dart';
7-
import 'package:pin_lock/src/entities/authenticator.dart';
8-
import 'package:pin_lock/src/entities/biometric_method.dart';
9-
import 'package:pin_lock/src/entities/lock_state.dart';
10-
import 'package:pin_lock/src/presentation/lock_screen/builders.dart';
11-
import 'package:pin_lock/src/presentation/lock_screen/configurations.dart';
12-
import 'package:pin_lock/src/presentation/widgets/pin_input_widget.dart';
137

148
/// Root widget of the part of the app that needs to be protected by the pin.
159
/// Takes the app's [Authenticator] as a parameter and makes sure that a lock
@@ -63,7 +57,7 @@ class AuthenticatorWidget extends StatefulWidget {
6357
required this.userFacingBiometricAuthenticationMessage,
6458
required this.inputNodeBuilder,
6559
this.splashScreenBuilder,
66-
this.splashScreenDuration = const Duration(),
60+
this.splashScreenDuration = Duration.zero,
6761
this.hideAppContent = true,
6862
this.iosImageAsset,
6963
}) : super(key: key);
@@ -80,8 +74,10 @@ class _AuthenticatorWidgetState extends State<AuthenticatorWidget> {
8074
@override
8175
void initState() {
8276
super.initState();
83-
PinLock.setHideAppContent(widget.hideAppContent,
84-
iosAssetImage: widget.iosImageAsset);
77+
PinLock.setHideAppContent(
78+
preference: widget.hideAppContent,
79+
iosAssetImage: widget.iosImageAsset,
80+
);
8581
lockSubscription = widget.authenticator.lockState.listen((event) {
8682
if (event is Unlocked) {
8783
overlayEntry?.remove();

lib/src/presentation/lock_screen/builders.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import 'package:pin_lock/src/presentation/lock_screen/configurations.dart';
33

44
/// Descibes the UI of the lock screen given the [LockScreenConfiguration]
55
typedef LockScreenBuilder = Widget Function(
6-
LockScreenConfiguration configuration);
6+
LockScreenConfiguration configuration,
7+
);

lib/src/presentation/lock_screen/configurations.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import 'package:equatable/equatable.dart';
2-
import 'package:flutter/foundation.dart';
32
import 'package:flutter/material.dart';
43
import 'package:pin_lock/pin_lock.dart';
5-
import 'package:pin_lock/src/entities/biometric_method.dart';
6-
import 'package:pin_lock/src/entities/failure.dart';
74

85
/// Provides information needed to draw the Lock Screen, such as the pin input widget
96
/// that needs to be placed on the LockScreen and available biometric methods that

0 commit comments

Comments
 (0)