Skip to content

"No MaterialLocalizations found" exception has a typo #48090

@Hixie

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.

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.f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions