Skip to content

[tool_crash] _CastError: (#0 LocalizationsGenerator._generateMethod.generateHelperMethods (package:flutter_tools/src/localizations/gen_l10n.dart:1214:54)) #116459

Description

@raresvanca

Command

flutter gen-l10n --verbose

Steps to Reproduce

  1. Upgrade flutter from stable to beta
  2. Run flutter gen-l10n --verbose

Logs

_CastError: (#0 LocalizationsGenerator._generateMethod.generateHelperMethods (package:flutter_tools/src/localizations/gen_l10n.dart:1214:54))

#0      LocalizationsGenerator._generateMethod.generateHelperMethods (package:flutter_tools/src/localizations/gen_l10n.dart:1214:54)
#1      LocalizationsGenerator._generateMethod.generateHelperMethods.<anonymous closure> (package:flutter_tools/src/localizations/gen_l10n.dart:1116:41)
#2      MappedListIterable.elementAt (dart:_internal/iterable.dart:414:31)
#3      ListIterator.moveNext (dart:_internal/iterable.dart:343:26)
#4      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#5      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#6      new List.of (dart:core-patch/array_patch.dart:52:28)
#7      ListIterable.toList (dart:_internal/iterable.dart:214:7)
#8      LocalizationsGenerator._generateMethod.generateHelperMethods (package:flutter_tools/src/localizations/gen_l10n.dart:1119:14)
#9      LocalizationsGenerator._generateMethod (package:flutter_tools/src/localizations/gen_l10n.dart:1280:5)
#10     LocalizationsGenerator._generateBaseClassFile.<anonymous closure> (package:flutter_tools/src/localizations/gen_l10n.dart:905:14)
#11     MappedIterator.moveNext (dart:_internal/iterable.dart:392:20)
#12     Iterable.join (dart:core/iterable.dart:431:23)
#13     LocalizationsGenerator._generateBaseClassFile (package:flutter_tools/src/localizations/gen_l10n.dart:919:41)
#14     LocalizationsGenerator._generateCode (package:flutter_tools/src/localizations/gen_l10n.dart:1015:46)
#15     LocalizationsGenerator.writeOutputFiles (package:flutter_tools/src/localizations/gen_l10n.dart:1286:47)
#16     generateLocalizations (package:flutter_tools/src/localizations/gen_l10n.dart:71:9)
#17     GenerateLocalizationsCommand.runCommand (package:flutter_tools/src/commands/generate_localizations.dart:228:24)
#18     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1423:12)
<asynchronous suspension>
#19     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1257:27)
<asynchronous suspension>
#20     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#21     CommandRunner.runCommand (package:args/command_runner.dart:209:13)
[✓] Flutter (Channel beta, 3.6.0-0.1.pre, on Ubuntu 22.10 5.19.0-26-generic, locale en_GB.UTF-8)
    • Flutter version 3.6.0-0.1.pre on channel beta at /home/rares/.apps/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 75927305ff (2 weeks ago), 2022-11-17 05:52:50 +0530
    • Engine revision b754eabc98
    • Dart version 2.19.0 (build 2.19.0-374.1.beta)
    • DevTools version 2.19.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /home/rares/.apps/android-sdk/
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /home/rares/.apps/jetbrains-toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 15.0.2-1
    • cmake version 3.24.2
    • ninja version 1.11.0
    • pkg-config version 0.29.2

[✓] Android Studio (version 2021.3)
    • Android Studio at /home/rares/.apps/jetbrains-toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.73.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.54.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.10 5.19.0-26-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 108.0.5359.94

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Flutter Application Metadata

Type: app
Version: 0.0.1+1
Material: true
Android X: false
Module: false
Plugin: false
Android package: null
iOS bundle identifier: null
Creation channel: beta
Creation framework version: d6260f1

Plugins

dynamic_color-1.5.4
flutter_native_splash-2.2.16
mobile_scanner-2.1.0
package_info_plus-3.0.2

Activity

  1. raresvanca commented on Dec 3, 2022

    @raresvanca
    Author

    Here is my l10n.yaml:

    arb-dir: lib/l10n
    template-arb-file: lw_en.arb
    output-localization-file: lw_localizations.dart
    output-class: LWLocalizations
    nullable-getter: false
  2. darshankawar commented on Dec 5, 2022

    @darshankawar
    Member

    I am unable to replicate the issue based on details provided. Keeping it open and labeling for team's attention.

  3. added
    c: crashStack traces logged to the console
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: internationalizationSupporting other languages or locales. (aka i18n)
    and removed
    in triagePresently being triaged by the triage team
    on Dec 5, 2022
  4. darshankawar commented on Dec 5, 2022

    @darshankawar
    Member
  5. raresvanca commented on Dec 5, 2022

    @raresvanca
    Author

    After some debugging it seems removing these lines from my arb is fixing the crash:

    "profileType": "{level, plural, =0{Novice} =1{Not bad} =2{TODO} =3{Gamer} other{True gamer}}",
    "@profileType": {
      "placeholders": {
        "level": {
          "description": "The level. Starts from 0",
          "format": "decimalPattern",
          "type": "num"
        }
      }
    },
  6. added
    P2Important issues not at the top of the work list
    on Dec 6, 2022
  7. christopherfujino commented on Dec 6, 2022

    @christopherfujino
    Contributor

    @thkim1011 it seems like this no longer affects the master channel with the new parser, is that correct?

  8. thkim1011 commented on Dec 6, 2022

    @thkim1011
    Contributor

    I think this may be a bug. Technically, the =3 or three case is not valid syntax, but I forgot to handle this case. I'll make a PR with a fix.

  9. self-assigned this
    on Dec 6, 2022
  10. thkim1011 commented on Dec 6, 2022

    @thkim1011
    Contributor

    @rares45 you might want to consider using a select case instead as follows:

    "profileType": "{level, select, level0{Novice} level1{Not bad} level2{TODO} level3{Gamer} other{True gamer}}",
    "@profileType": {
      "placeholders": {
        "level": {
          "description": "The level. Starts from 0",
          "format": "decimalPattern",
          "type": "String"
        }
      }
    },
    

    and use the string with LWLocalizations.of(context).profileType('level$level').

    Currently, it will throw a syntax error if numbers are used for select cases instead of alphanumeric strings, but I'm working on a fix for this as well.

  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on Dec 9, 2022
  12. github-actions commented on Mar 5, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)c: crashStack traces logged to the consoler: fixedIssue is closed as already fixed in a newer versiontoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions