aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.32k stars 246 forks source link

Errors: Type 'AuthenticatorStep' not found and 'AuthenticatorStep' isn't a type. #2594

Closed stouvoli closed 1 year ago

stouvoli commented 1 year ago

Description

Running my application is not working. I get error message below saying 'AuthenticatorStep' not found and 'AuthenticatorStep' isn't a type. I have setup localization and it is working fine except when I add the line below in the arb file.

  "@backTo": {
    "description": "Label of button to return to the previous step",
    "placeholders": {
      "previousStep": {
        "type": "AuthenticatorStep",
        "example": "signIn",
        "description": "The title of the previous step."
      }
    }
  },

The amplify_authenticator package is apparently correctly configured but the AuthenticatorStep enum is not visible from the generated arb files .dart_tool/flutter_gen/gen_l10n/app_localizations.dart, .dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart and .dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart.

Error message;

> Launching lib\main.dart on sdk gphone x86 in debug mode...
> Running Gradle task 'assembleDebug'...
> .dart_tool/flutter_gen/gen_l10n/app_localizations.dart:154:17: Error: Type 'AuthenticatorStep' not found.
>   String backTo(AuthenticatorStep previousStep);
>                 ^^^^^^^^^^^^^^^^^
> .dart_tool/flutter_gen/gen_l10n/app_localizations.dart:154:17: Error: 'AuthenticatorStep' isn't a type.
>   String backTo(AuthenticatorStep previousStep);
>                 ^^^^^^^^^^^^^^^^^
> .dart_tool/flutter_gen/gen_l10n/app_localizations_fr.dart:37:17: Error: Type 'AuthenticatorStep' not found.
>   String backTo(AuthenticatorStep previousStep) {
>                 ^^^^^^^^^^^^^^^^^
> .dart_tool/flutter_gen/gen_l10n/app_localizations_fr.dart:37:17: Error: 'AuthenticatorStep' isn't a type.
>   String backTo(AuthenticatorStep previousStep) {
>                 ^^^^^^^^^^^^^^^^^
> .dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart:37:17: Error: Type 'AuthenticatorStep' not found.
>   String backTo(AuthenticatorStep previousStep) {
>                 ^^^^^^^^^^^^^^^^^
> .dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart:37:17: Error: 'AuthenticatorStep' isn't a type.
>   String backTo(AuthenticatorStep previousStep) {
>                 ^^^^^^^^^^^^^^^^^
> 
> 
> FAILURE: Build failed with an exception.
> 
> * Where:
> Script 'C:\Users\stouvoli\data\tools\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159
> 
> * What went wrong:
> Execution failed for task ':app:compileFlutterBuildDebug'.
> > Process 'command 'C:\Users\stouvoli\data\tools\flutter\bin\flutter.bat'' finished with non-zero exit value 1
> 
> * Try:
> > Run with --stacktrace option to get the stack trace.
> > Run with --info or --debug option to get more log output.
> > Run with --scan to get full insights.
> 
> * Get more help at https://help.gradle.org
> 
> BUILD FAILED in 12s
> Exception: Gradle task assembleDebug failed with exit code 1
> 

Eveything esle is working except this backTo.

class LocalizedButtonResolver extends ButtonResolver {
  const LocalizedButtonResolver();

  @override
  String signIn(BuildContext context) {
    return AppLocalizations.of(context)!.signin;
  }

  @override
  String signUp(BuildContext context) {
    return AppLocalizations.of(context)!.signup;
  }

  @override
  String forgotPassword(BuildContext context) {
    return AppLocalizations.of(context)!.forgotPassword;
  }

  @override
  String sendCode(BuildContext context) {
    return AppLocalizations.of(context)!.sendCode;
  }

  @override
  String submit(BuildContext context) {
    return AppLocalizations.of(context)!.submit;
  }

  @override
  String backTo(BuildContext context, AuthenticatorStep previousStep) {
    return AppLocalizations.of(context)!.backTo(previousStep);
  }
}

Categories

Steps to Reproduce

  1. Create a flutter app and setup amplify as explained on doc https://docs.amplify.aws/start/q/integration/flutter/.
  2. Add dependecies:
    cupertino_icons: ^1.0.2
    amplify_flutter: ^0.6.10
    amplify_datastore: ^0.6.10
    amplify_auth_cognito: ^0.6.10
    amplify_api: ^0.6.10
    amplify_storage_s3: ^0.6.10
    amplify_authenticator: ^0.2.4
    url_launcher: ^6.1.7
    http: ^0.13.5
  3. Activate localization as explained here: https://docs.flutter.dev/development/accessibility-and-localization/internationalization
  4. Configure amplify login as explained here: https://ui.docs.amplify.aws/flutter/connected-components/authenticator/configuration
  5. Configure amplify login localization as explained here: https://ui.docs.amplify.aws/flutter/connected-components/authenticator/customization#internationalization-i18n
  6. Update the arb file with line below:
    "backTo": "Retour à {previousStep, select, signUp{Sign Up}, signIn{Sign In}, confirmSignUp{Confirm Sign-up}, confirmSignInMfa{Confirm Sign-in} confirmSignInNewPassword{Confirm Sign-in} sendCode{Send Code} resetPassword{Reset Password} verifyUser{Verify User} confirmVerifyUser{Confirm Verify User}}",
    "@backTo": {
    "description": "Label of button to return to the previous step",
    "placeholders": {
      "previousStep": {
        "type": "AuthenticatorStep",
        "example": "signIn",
        "description": "The title of the previous step."
      }
    }
    },

    Try to run the app.

Screenshots

No response

Platforms

Android Device/Emulator API Level

API 30

Environment

(base) PS C:\Users\stouvoli\data\Trainings\Exercices\Flutter\numappdemo> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.22621.1105], locale fr-FR)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.2)
[!] Android Studio (version 2022.1)
    X Unable to find bundled Java version.
[√] IntelliJ IDEA Community Edition (version 2021.2)
[√] IntelliJ IDEA Community Edition (version 2022.1)
[√] Connected device (4 available)
[√] HTTP Host Availability

! Doctor found issues in 1 category.
(base) PS C:\Users\stouvoli\data\Trainings\Exercices\Flutter\numappdemo>

Dependencies

(base) PS C:\Users\stouvoli\data\Trainings\Exercices\Flutter\numappdemo> flutter pub deps --no-dev --style=compact
Dart SDK 2.18.6
Flutter SDK 3.3.10
numappdemo 1.0.0+1

dependencies:
- amplify_api 0.6.11 [amplify_api_android amplify_api_ios amplify_core amplify_flutter aws_common collection flutter meta plugin_platform_interface]
- amplify_auth_cognito 0.6.11 [amplify_auth_cognito_android amplify_auth_cognito_ios amplify_core aws_common collection flutter meta plugin_platform_interface]
- amplify_authenticator 0.2.4 [amplify_auth_cognito amplify_core amplify_flutter async aws_common collection flutter flutter_localizations intl stream_transform]
- amplify_datastore 0.6.11 [flutter amplify_datastore_plugin_interface amplify_core plugin_platform_interface meta collection async]
- amplify_flutter 0.6.11 [amplify_core amplify_datastore_plugin_interface amplify_flutter_android amplify_flutter_ios aws_common collection flutter meta plugin_platform_interface]
- amplify_storage_s3 0.6.11 [amplify_storage_s3_android amplify_storage_s3_ios amplify_core aws_common flutter meta plugin_platform_interface path_provider path]
- cupertino_icons 1.0.5
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- http 0.13.5 [async http_parser meta path]
- intl 0.17.0 [clock path]
- url_launcher 6.1.8 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]

transitive dependencies:
- amplify_api_android 0.6.11 [flutter]
- amplify_api_ios 0.6.11 [amplify_core flutter]
- amplify_auth_cognito_android 0.6.11 [flutter]
- amplify_auth_cognito_ios 0.6.11 [amplify_core flutter]
- amplify_core 0.6.11 [aws_common collection flutter intl json_annotation meta plugin_platform_interface uuid]
- amplify_datastore_plugin_interface 0.6.11 [amplify_core collection flutter meta]
- amplify_flutter_android 0.6.11 [flutter]
- amplify_flutter_ios 0.6.11 [amplify_core flutter]
- amplify_storage_s3_android 0.6.11 [flutter]
- amplify_storage_s3_ios 0.6.11 [flutter]
- async 2.9.0 [collection meta]
- aws_common 0.1.1 [async collection http meta stream_transform uuid]
- characters 1.2.1
- clock 1.1.1
- collection 1.16.0
- crypto 3.0.2 [typed_data]
- ffi 2.0.1
- file 6.1.4 [meta path]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- js 0.6.4
- json_annotation 4.8.0 [meta]
- material_color_utilities 0.1.5
- meta 1.8.0
- path 1.8.2
- path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows]
- path_provider_android 2.0.22 [flutter path_provider_platform_interface]
- path_provider_ios 2.0.11 [flutter path_provider_platform_interface]
- path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_macos 2.0.7 [flutter path_provider_platform_interface]
- path_provider_platform_interface 2.0.5 [flutter platform plugin_platform_interface]
- path_provider_windows 2.1.3 [ffi flutter path path_provider_platform_interface win32]
- platform 3.1.0
- plugin_platform_interface 2.1.3 [meta]
- process 4.2.4 [file path platform]
- sky_engine 0.0.99
- source_span 1.9.0 [collection path term_glyph]
- stream_transform 2.1.0
- string_scanner 1.1.1 [source_span]
- term_glyph 1.2.1
- typed_data 1.3.1 [collection]
- url_launcher_android 6.0.23 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.0.18 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.0.2 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.0.2 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.1.1 [flutter plugin_platform_interface]
- url_launcher_web 2.0.14 [flutter flutter_web_plugins url_launcher_platform_interface]
- url_launcher_windows 3.0.2 [flutter url_launcher_platform_interface]
- uuid 3.0.6 [crypto]
- vector_math 2.1.2
- win32 3.1.3 [ffi]
- xdg_directories 0.2.0+3 [meta path process]
(base) PS C:\Users\stouvoli\data\Trainings\Exercices\Flutter\numappdemo>

Device

N/A

OS

N/A

Deployment Method

Amplify CLI

CLI Version

10.5.2

Additional Context

No response

Amplify Config

const amplifyconfig = ''' {
    "UserAgent": "aws-amplify-cli/2.0",
    "Version": "1.0",
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "UserAgent": "aws-amplify-cli/0.1.0",
                "Version": "0.1.0",
                "IdentityManager": {
                    "Default": {}
                },
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "xxxxx",
                            "Region": "xxx"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "xxxx",
                        "AppClientId": "xxxx",
                        "Region": "xxxx"
                    }
                },
                "Auth": {
                    "Default": {
                        "authenticationFlowType": "USER_SRP_AUTH",
                        "mfaConfiguration": "ON",
                        "mfaTypes": [
                            "TOTP"
                        ],
                        "passwordProtectionSettings": {
                            "passwordPolicyMinLength": 10,
                            "passwordPolicyCharacters": [
                                "REQUIRES_LOWERCASE",
                                "REQUIRES_NUMBERS",
                                "REQUIRES_SYMBOLS",
                                "REQUIRES_UPPERCASE"
                            ]
                        },
                        "signupAttributes": [
                            "EMAIL",
                            "PHONE_NUMBER",
                            "NAME",
                            "FAMILY_NAME"
                        ],
                        "socialProviders": [],
                        "usernameAttributes": [],
                        "verificationMechanisms": [
                            "EMAIL"
                        ]
                    }
                }
            }
        }
    }
}''';
stouvoli commented 1 year ago

Hello, Nobody to help on this?

dnys1 commented 1 year ago

Hi @stouvoli - apologies for the late reply. In order for this type to be visible to your localizations, can you please try adding the following to your l10n.yaml file:

header: |
  import 'package:amplify_authenticator/amplify_authenticator.dart';

Alternatively you can pass this as a flag to the flutter gen-l10n command:

$ flutter gen-l10n \
    --header="import 'package:amplify_authenticator/amplify_authenticator.dart';" \
    # ... other params
stouvoli commented 1 year ago

Hello @dnys1,

Thanks for your reply. I have just checked my project. I see today another error message no more related to enum AuthenticatorStep. I do not know why but this enum is now visible from the project files. The new error is related to a syntaxe error in the Autenticator package buttons_en.arb file. The select statement is not correct. But I can solve this one. Thanks

"backTo": "Back to {previousStep, select, signUp{Sign Up}, signIn{Sign In}, confirmSignUp{Confirm Sign-up}, confirmSignInMfa{Confirm Sign-in} confirmSignInNewPassword{Confirm Sign-in} sendCode{Send Code} resetPassword{Reset Password} verifyUser{Verify User} confirmVerifyUser{Confirm Verify User}}", "@backTo": { "description": "Label of button to return to the previous step", "placeholders": { "previousStep": { "type": "AuthenticatorStep", "example": "signIn", "description": "The title of the previous step." } } },

1st error

Generating synthetic localizations package failed with 1 error: Exception: Placeholders used in selects must be of type 'String'

2nd error

[app_fr.arb:backTo] ICU Syntax Error: Expected "}" but found ",".

3rd error

[app_fr.arb:backTo] ICU Syntax Error: Select expressions must have an "other" case.