Skip to content

Commit

Permalink
Merge pull request #12 from DutchCodingCompany/feature/update_lints
Browse files Browse the repository at this point in the history
Lint updates
  • Loading branch information
Guldem authored Feb 21, 2023
2 parents f994265 + e149433 commit eb29fb1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 59 deletions.
14 changes: 5 additions & 9 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
include: package:lint/analysis_options.yaml
include: package:flutter_lints/flutter.yaml

analyzer:
exclude:
- "lib/**/*.g.dart"
- "lib/**/*.freezed.dart"
- "lib/**/*.mocks.dart"
errors:
todo: info
enable-experiment:
- nonfunction-type-aliases
exclude:
- "lib/**/*.mocks.dart"
errors:
todo: info

linter:
rules:
Expand Down
6 changes: 3 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class _MyAppState extends State<MyApp> {
theme: ThemeData(
primarySwatch: Colors.indigo,
textTheme: TextTheme(
bodyText2: TextStyle(color: Colors.indigo),
bodyMedium: TextStyle(color: Colors.indigo),
),
),

Expand Down Expand Up @@ -96,7 +96,7 @@ class _InputField extends StatelessWidget {
@override
Widget build(BuildContext context) {
final borderColor = state == InputFieldState.error
? Theme.of(context).errorColor
? Theme.of(context).colorScheme.error
: Theme.of(context).primaryColor;
double borderWidth = 1;
if (state == InputFieldState.focused ||
Expand Down Expand Up @@ -142,7 +142,7 @@ class _Home extends StatelessWidget {
children: [
Text(
'This is the home screen',
style: Theme.of(context).textTheme.headline3,
style: Theme.of(context).textTheme.displaySmall,
textAlign: TextAlign.center,
),
TextButton(
Expand Down
26 changes: 10 additions & 16 deletions lib/src/entities/authenticator_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
final lastActive = await _repository.getPausedTimestamp();
if (lastActive != null) {
final now = DateTime.now();
if (now.millisecondsSinceEpoch - lastActive.millisecondsSinceEpoch >
lockAfterDuration.inMilliseconds) {
if (now.millisecondsSinceEpoch - lastActive.millisecondsSinceEpoch > lockAfterDuration.inMilliseconds) {
_lockController.lock(
availableMethods: await getAvailableBiometricMethods(),
);
Expand Down Expand Up @@ -210,6 +209,8 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
case BiometricType.iris:
methods.add(BiometricMethod.iris);
break;
default:
break;
}
}
return methods;
Expand All @@ -221,15 +222,13 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
if (!isSupported) {
return const Unavailable(reason: LocalAuthFailure.notAvailable);
}
final storedValue =
await _repository.isBiometricAuthenticationEnabled(userId: userId);
final storedValue = await _repository.isBiometricAuthenticationEnabled(userId: userId);
return Available(isEnabled: storedValue ?? false);
}

@override
Future<bool> isPinAuthenticationEnabled() async {
final storedValue =
await _repository.isPinAuthenticationEnabled(userId: userId);
final storedValue = await _repository.isPinAuthenticationEnabled(userId: userId);
return storedValue ?? false;
}

Expand Down Expand Up @@ -263,8 +262,7 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
Future<Either<LocalAuthFailure, Unit>> unlockWithBiometrics({
required String userFacingExplanation,
}) async {
final biometricAvailability =
await getBiometricAuthenticationAvailability();
final biometricAvailability = await getBiometricAuthenticationAvailability();
if (biometricAvailability is Available) {
if (!biometricAvailability.isEnabled) {
_lockController.lock(availableMethods: const []);
Expand All @@ -277,7 +275,7 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
try {
final isSuccessful = await _biometricAuth.authenticate(
localizedReason: userFacingExplanation,
options: AuthenticationOptions(biometricOnly: true),
options: const AuthenticationOptions(biometricOnly: true),
);
if (isSuccessful) {
_lockController.unlock();
Expand All @@ -304,11 +302,9 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
}

Future<bool> _isLockedDueToTooManyAttempts() async {
final failedAttemptsList =
await _repository.getListOfFailedAttempts(userId: userId);
final failedAttemptsList = await _repository.getListOfFailedAttempts(userId: userId);
if (failedAttemptsList.length > maxRetries) {
if (DateTime.now().difference(failedAttemptsList.last) <
lockedOutDuration) {
if (DateTime.now().difference(failedAttemptsList.last) < lockedOutDuration) {
return true;
}
}
Expand All @@ -323,9 +319,7 @@ class AuthenticatorImpl with WidgetsBindingObserver implements Authenticator {
final biometric = await getBiometricAuthenticationAvailability();
if (biometric is Available) {
_lockController.lock(
availableMethods: biometric.isEnabled
? await getAvailableBiometricMethods()
: const [],
availableMethods: biometric.isEnabled ? await getAvailableBiometricMethods() : const [],
);
}
if (biometric is Unavailable) {
Expand Down
15 changes: 6 additions & 9 deletions lib/src/presentation/authenticator_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class AuthenticatorWidget extends StatefulWidget {
}) : super(key: key);

@override
_AuthenticatorWidgetState createState() => _AuthenticatorWidgetState();
State<AuthenticatorWidget> createState() => _AuthenticatorWidgetState();
}

class _AuthenticatorWidgetState extends State<AuthenticatorWidget> {
Expand Down Expand Up @@ -92,12 +92,11 @@ class _AuthenticatorWidgetState extends State<AuthenticatorWidget> {
builder: widget.lockScreenBuilder,
inputNodeBuilder: widget.inputNodeBuilder,
availableMethods: event.availableBiometricMethods,
userFacingMessage:
widget.userFacingBiometricAuthenticationMessage,
userFacingMessage: widget.userFacingBiometricAuthenticationMessage,
),
);
if (!_isShowingSplashScreen) {
Overlay.of(context)?.insert(overlayEntry!);
Overlay.of(context).insert(overlayEntry!);
}
}
}
Expand All @@ -106,7 +105,7 @@ class _AuthenticatorWidgetState extends State<AuthenticatorWidget> {
setState(() {
_isShowingSplashScreen = false;
if (overlayEntry != null) {
Overlay.of(context)?.insert(overlayEntry!);
Overlay.of(context).insert(overlayEntry!);
}
});
});
Expand All @@ -126,8 +125,7 @@ class _AuthenticatorWidgetState extends State<AuthenticatorWidget> {
if (snapshot.hasData && !_isShowingSplashScreen) {
return widget.child;
}
return widget.splashScreenBuilder?.call() ??
const Center(child: CircularProgressIndicator());
return widget.splashScreenBuilder?.call() ?? const Center(child: CircularProgressIndicator());
},
);
}
Expand Down Expand Up @@ -170,8 +168,7 @@ class _LockScreen extends StatelessWidget {
error: state.error,
availableBiometricMethods: availableMethods,
onBiometricAuthenticationRequested: () {
BlocProvider.of<LockCubit>(context)
.unlockWithBiometrics(userFacingMessage);
BlocProvider.of<LockCubit>(context).unlockWithBiometrics(userFacingMessage);
},
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/presentation/widgets/pin_input_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PinInputWidget extends StatefulWidget {
}) : super(key: key);

@override
_PinInputWidgetState createState() => _PinInputWidgetState();
State<PinInputWidget> createState() => _PinInputWidgetState();
}

class _PinInputWidgetState extends State<PinInputWidget> {
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.1.7
lint: ^1.5.3
mockito: ^5.0.17
build_runner: ^2.3.3
flutter_lints: ^2.0.1
mockito: ^5.3.2

flutter:
plugin:
Expand Down
18 changes: 0 additions & 18 deletions test/pin_lock_test.dart

This file was deleted.

0 comments on commit eb29fb1

Please sign in to comment.