Skip to content

"No MaterialLocalizations found" exception has a typo #48090

Closed

Description

@Hixie

For reasons that don't matter here, I got the following exception:

E/flutter (18304): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: No MaterialLocalizations found.
E/flutter (18304): MyApp widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
E/flutter (18304): Localizations are used to generate many different messages, labels,and abbreviations which are used by the material library.
E/flutter (18304): To introduce a MaterialLocalizations, either use a MaterialApp at the root of your application to include them automatically, or add a Localization widget with a MaterialLocalizations delegate.
E/flutter (18304): The specific widget that could not find a MaterialLocalizations ancestor was:
E/flutter (18304):   MyApp
E/flutter (18304): The ancestors of this widget were:
E/flutter (18304):   [root]

Notice the typo on the third line, labels,and.

Ironically, we even hard-coded this typo into the relevant test:

' labels,and abbreviations which are used by the material library.\n'

This is caused by omitting a space character at the end of one string in a multiline multipart string literal:

'Localizations are used to generate many different messages, labels,'

To catch these in the future, we should write a test (or a lint) that looks for adjacent string literals where the last character of the first literal is not whitespace (U+0020 or U+000A).

cc @a14n if this is something that would be easy to lint.

Activity

  1. added
    c: contributor-productivityTeam-specific productivity, code health, technical debt.
    frameworkflutter/packages/flutter repository. See also f: labels.
    a: qualityA truly polished experience
    on Jan 2, 2020
  2. added this to the milestone on Jan 2, 2020
  3. github-actions commented on Aug 13, 2021

    @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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: internationalizationSupporting other languages or locales. (aka i18n)a: qualityA truly polished experiencec: contributor-productivityTeam-specific productivity, code health, technical debt.frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions