Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Lint fixes #1471

Merged
merged 13 commits into from
Apr 29, 2022
2 changes: 1 addition & 1 deletion packages/amplify/amplify_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);

@override
_MyAppState createState() => _MyAppState();
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
Expand Down
2 changes: 2 additions & 0 deletions packages/amplify/amplify_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ dev_dependencies:
path: ../../../auth/amplify_auth_cognito
amplify_datastore:
path: ../../../amplify_datastore
amplify_datastore_plugin_interface:
path: ../../../amplify_datastore_plugin_interface
amplify_lints: ^1.0.0
amplify_storage_s3:
path: ../../../storage/amplify_storage_s3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AmplifyPluginRegistry {
}

/// The global, shared plugin registry.
static late final shared = AmplifyPluginRegistry._();
static final shared = AmplifyPluginRegistry._();

final Map<String, AmplifyPluginConfigFactory> _plugins = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,16 @@ class MethodChannelAmplify extends AmplifyClass {
await API.addPlugin(plugin);
} else {
throw AmplifyException(
'The type of plugin ' +
plugin.runtimeType.toString() +
' is not yet supported in Amplify.',
recoverySuggestion:
AmplifyExceptionMessages.missingRecoverySuggestion);
'The type of plugin ${plugin.runtimeType} is not yet supported '
'in Amplify.',
recoverySuggestion:
AmplifyExceptionMessages.missingRecoverySuggestion,
);
}
} on Exception catch (e) {
safePrint('Amplify plugin was not added');
throw AmplifyException(
'Amplify plugin ' +
plugin.runtimeType.toString() +
' was not added successfully.',
'Amplify plugin ${plugin.runtimeType} was not added successfully.',
recoverySuggestion: AmplifyExceptionMessages.missingRecoverySuggestion,
underlyingException: e.toString(),
);
Expand All @@ -96,9 +94,10 @@ class MethodChannelAmplify extends AmplifyClass {
// Validation #1
if (_isConfigured) {
throw const AmplifyAlreadyConfiguredException(
'Amplify has already been configured and re-configuration is not supported.',
recoverySuggestion:
'Check if Amplify is already configured using Amplify.isConfigured.',
'Amplify has already been configured and re-configuration is '
'not supported.',
recoverySuggestion: 'Check if Amplify is already configured using '
'Amplify.isConfigured.',
);
}

Expand Down
1 change: 0 additions & 1 deletion packages/amplify_authenticator/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ analyzer:
- tool/*.dart
errors:
public_member_api_docs: ignore
implementation_imports: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ String generatePassword() =>
/// generates a fake US phone number using a reserved number in the North America
///
/// See https://en.wikipedia.org/wiki/Fictitious_telephone_number#North_American_Numbering_Plan
_PhoneNumber generateUSPhoneNumber() => _PhoneNumber(
PhoneNumber generateUSPhoneNumber() => PhoneNumber(
countryCode: '+1',
areaCode: '555',
phoneNumber: '01${randomPhoneDigits(2)}',
Expand All @@ -46,7 +46,7 @@ _PhoneNumber generateUSPhoneNumber() => _PhoneNumber(
/// generates a fake french phone number using a reserved number in france
///
/// See https://en.wikipedia.org/wiki/Fictitious_telephone_number#France
_PhoneNumber generateFrenchPhoneNumber() => _PhoneNumber(
PhoneNumber generateFrenchPhoneNumber() => PhoneNumber(
countryCode: '+33',
areaCode: '1',
phoneNumber: '9900${randomPhoneDigits(4)}',
Expand All @@ -64,12 +64,12 @@ String randomPhoneDigits(int count) {
return value;
}

class _PhoneNumber {
class PhoneNumber {
final String countryCode;
final String? areaCode;
final String phoneNumber;

_PhoneNumber({
PhoneNumber({
required this.countryCode,
this.areaCode = '',
required this.phoneNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class TermsAndConditionsCheckBox extends FormField<bool> {
if (value != true) {
return 'You must agree to the terms and conditions';
}
return null;
},
initialValue: false,
builder: (FormFieldState<bool> state) {
Expand Down
2 changes: 0 additions & 2 deletions packages/amplify_authenticator/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_authenticator/amplify_authenticator.dart';
import 'package:amplify_authenticator_example/customization/authenticator_with_custom_layout.dart';
import 'package:amplify_authenticator_example/customization/authenticator_with_onboarding.dart';
import 'package:amplify_authenticator_example/resolvers/localized_button_resolver.dart';
import 'package:amplify_authenticator_example/resolvers/localized_country_resolver.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LocalizedButtonResolver extends ButtonResolver {
}

@override
String signOut(BuildContext context) {
String signout(BuildContext context) {
return AppLocalizations.of(context).signOut;
}

Expand Down
1 change: 1 addition & 0 deletions packages/amplify_authenticator/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dev_dependencies:
integration_test:
sdk: flutter
stream_transform: ^2.0.0
uuid: ^3.0.0

flutter:
uses-material-design: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ class Authenticator extends StatefulWidget {
final AuthenticatorStep initialStep;

@override
_AuthenticatorState createState() => _AuthenticatorState();
State<Authenticator> createState() => _AuthenticatorState();

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ import 'package:flutter/material.dart';

import 'authenticator_localizations.dart';

enum _MessageResolverKey {
enum MessageResolverKeyType {
codeSent,
}

class MessageResolverKey {
final _MessageResolverKey key;
final MessageResolverKeyType type;
final String? destination;

const MessageResolverKey._(this.key, this.destination);
const MessageResolverKey._(this.type, this.destination);

const MessageResolverKey.codeSent(String? destination)
: this._(
_MessageResolverKey.codeSent,
MessageResolverKeyType.codeSent,
destination,
);
}
Expand All @@ -53,8 +53,8 @@ class MessageResolver extends Resolver<MessageResolverKey> {

@override
String resolve(BuildContext context, MessageResolverKey key) {
switch (key.key) {
case _MessageResolverKey.codeSent:
switch (key.type) {
case MessageResolverKeyType.codeSent:
var destination = key.destination;
if (destination != null) {
return codeSent(context, destination);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ mixin AuthenticatorPhoneFieldMixin<FieldType,
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: InkWell(
key: keySelectCountryCode,
onTap: showCountryDialog,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand All @@ -88,7 +89,6 @@ mixin AuthenticatorPhoneFieldMixin<FieldType,
const SizedBox(width: 5),
],
),
onTap: showCountryDialog,
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ mixin AuthenticatorRadioField<FieldType, FieldValue,
value: selection.value,
groupValue: selectionValue,
onChanged: (FieldValue? value) {
setState(() {
_selectionValue = value!;
});
if (value != null) {
setState(() {
_selectionValue = value;
});
}
if (selectionValue != null) onChanged(selectionValue!);
},
activeColor: Theme.of(context).primaryColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,24 @@ mixin AuthenticatorUsernameField<FieldType,
return ToggleButtons(
borderWidth: buttonBorderWidth,
constraints: buttonConstraints,
children: [
Text(emailTitle),
Text(phoneNumberTitle),
],
isSelected: [useEmail.value, !useEmail.value],
onPressed: (int index) {
bool _useEmail = index == 0;
bool useEmail = index == 0;
setState(() {
useEmail.value = _useEmail;
this.useEmail.value = useEmail;
});
// Reset current username value to align with the current switch state.
String newUsername = _useEmail
String newUsername = useEmail
? state.getAttribute(CognitoUserAttributeKey.email) ?? ''
: state.getAttribute(
CognitoUserAttributeKey.phoneNumber) ??
'';
state.username = newUsername;
},
children: [
Text(emailTitle),
Text(phoneNumberTitle),
],
);
}),
SizedBox(height: marginBottom),
Expand Down Expand Up @@ -230,8 +230,8 @@ mixin AuthenticatorUsernameField<FieldType,
}

String? _validator(String? username) {
final _validator = widget.validatorOverride ?? validator;
return _validator(UsernameInput(
final validator = widget.validatorOverride ?? this.validator;
return validator(UsernameInput(
type: selectedUsernameType,
username: username ?? '',
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ class AuthenticatorTabView
final int initialIndex;

@override
_AuthenticatorTabViewState createState() => _AuthenticatorTabViewState();
AuthenticatorComponentState<AuthenticatorTabView> createState() =>
_AuthenticatorTabViewState();

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
Expand Down
7 changes: 4 additions & 3 deletions packages/amplify_authenticator/lib/src/widgets/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ abstract class AuthenticatorElevatedButton
Widget? get loadingIndicator => const AmplifyProgressIndicator();

@override
_AmplifyElevatedButtonState createState() => _AmplifyElevatedButtonState();
AuthenticatorButtonState<AuthenticatorElevatedButton> createState() =>
_AmplifyElevatedButtonState();
}

class _AmplifyElevatedButtonState
Expand Down Expand Up @@ -310,11 +311,11 @@ class LostCodeButton extends StatelessAuthenticatorComponent {
),
),
TextButton(
onPressed: state.resendSignUpCode,
child: Text(
buttonResolver.sendCode(context),
style: const TextStyle(fontSize: fontSize),
),
onPressed: state.resendSignUpCode,
),
],
),
Expand Down Expand Up @@ -473,14 +474,14 @@ class SkipVerifyUserButton extends StatelessAuthenticatorComponent {
) {
return TextButton(
key: keySkipVerifyUserButton,
onPressed: state.skipVerifyUser,
child: Text(
stringResolver.buttons.skip(context),
style: TextStyle(
fontSize: AuthenticatorButtonConstants.fontSize,
color: Theme.of(context).primaryColor,
),
),
onPressed: state.skipVerifyUser,
);
}
}
11 changes: 6 additions & 5 deletions packages/amplify_authenticator/lib/src/widgets/checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AuthenticatorCheckbox<T extends AuthenticatorCheckbox<T>>
}

@override
_AuthenticatorCheckBoxState<T> createState() =>
AuthenticatorComponentState<T> createState() =>
_AuthenticatorCheckBoxState<T>();
}

Expand All @@ -56,13 +56,14 @@ class _AuthenticatorCheckBoxState<T extends AuthenticatorCheckbox<T>>
return CheckboxListTile(
title: Text(checkboxResolver.resolve(context, widget.labelKey)),
value: _isChecked,
tristate: false,
onChanged: (value) {
// Checkbox value can only be true/false since tristate is false.
var _value = value!;
final boolValue = value!;
setState(() {
_isChecked = _value;
_isChecked = boolValue;
});
onChanged(_value);
onChanged(boolValue);
},
controlAffinity: ListTileControlAffinity.leading,
);
Expand All @@ -81,7 +82,7 @@ class RememberDeviceCheckbox
: super(key: key, labelKey: InputResolverKey.rememberDevice);

@override
_RememberDeviceCheckboxState<RememberDeviceCheckbox> createState() =>
AuthenticatorComponentState<RememberDeviceCheckbox> createState() =>
_RememberDeviceCheckboxState<RememberDeviceCheckbox>();
}

Expand Down
10 changes: 5 additions & 5 deletions packages/amplify_authenticator/lib/src/widgets/form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class AuthenticatorFormState<T extends AuthenticatorForm>
);
}

final _runtimeActions = runtimeActions(context);
final runtimeActions = this.runtimeActions(context);
return Form(
key: formKey,
child: Column(
Expand All @@ -203,9 +203,9 @@ class AuthenticatorFormState<T extends AuthenticatorForm>
children: [
if (widget.actions.isNotEmpty) const SizedBox(height: 4),
...widget.actions,
if (_runtimeActions.isNotEmpty) ...[
if (runtimeActions.isNotEmpty) ...[
const Divider(),
..._runtimeActions,
...runtimeActions,
]
].spacedBy(const SizedBox(height: 12)),
),
Expand Down Expand Up @@ -263,7 +263,7 @@ class SignUpForm extends AuthenticatorForm {
final bool _includeDefaultFields;

@override
_SignUpFormState createState() => _SignUpFormState();
AuthenticatorFormState<SignUpForm> createState() => _SignUpFormState();
}

class _SignUpFormState extends AuthenticatorFormState<SignUpForm> {
Expand Down Expand Up @@ -396,7 +396,7 @@ class SignInForm extends AuthenticatorForm {
);

@override
_SignInFormState createState() => _SignInFormState();
AuthenticatorFormState<SignInForm> createState() => _SignInFormState();
}

class _SignInFormState extends AuthenticatorFormState<SignInForm> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,11 @@ class _ConfirmSignInPhoneFieldState extends _ConfirmSignInTextFieldState
with AuthenticatorPhoneFieldMixin {
@override
String? get initialValue {
var _initialValue = state.getAttribute(CognitoUserAttributeKey.phoneNumber);
if (_initialValue != null) {
_initialValue = displayPhoneNumber(_initialValue);
var initialValue = state.getAttribute(CognitoUserAttributeKey.phoneNumber);
if (initialValue != null) {
initialValue = displayPhoneNumber(initialValue);
}
return _initialValue;
return initialValue;
}

@override
Expand Down
Loading