Skip to content

[flutter_tools] Support standalone UI packages in gen-l10n - #194500

Draft
bkonyi wants to merge 3 commits into
flutter:masterfrom
bkonyi:issue-191072
Draft

bkonyi wants to merge 3 commits into
flutter:masterfrom
bkonyi:issue-191072

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Updates LocalizationsGenerator and gen-l10n templates to support applications migrated to standalone UI packages (package:material_ui and package:cupertino_ui). Inspects pubspec.yaml dependencies to emit the matching package import alongside GlobalMaterialLocalizations.delegates or GlobalCupertinoLocalizations.delegates in the generated localizations file.

Fixes #191072

bkonyi added 3 commits August 19, 2026 16:30
Use `...GlobalMaterialLocalizations.delegates` in `AppLocalizations.localizationsDelegates`
instead of referencing individual `.delegate` getters on each global
localization class. This ensures compatibility with both `flutter_localizations`
and standalone UI packages (such as `material_ui` and `cupertino_ui`).

Fixes flutter#191072
@bkonyi bkonyi added the CICD Run CI/CD label Oct 15, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for standalone UI packages (material_ui and cupertino_ui) in localizations generation by reading the project's pubspec.yaml dependencies and dynamically adjusting the imported packages and default localization delegates. Feedback on these changes highlights a compilation error due to an undefined logger variable (which should be _logger) and recommends caching the parsed dependencies to avoid inefficient, repetitive I/O operations.

Comment on lines +1220 to +1224
final FlutterManifest? flutterManifest = FlutterManifest.createFromPath(
projectDirectory.childFile('pubspec.yaml').path,
fileSystem: _fs,
logger: logger,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The field for the logger in LocalizationsGenerator is _logger (with a leading underscore). Using logger here will result in a compilation error because logger is not defined in this scope.

Suggested change
final FlutterManifest? flutterManifest = FlutterManifest.createFromPath(
projectDirectory.childFile('pubspec.yaml').path,
fileSystem: _fs,
logger: logger,
);
final FlutterManifest? flutterManifest = FlutterManifest.createFromPath(
projectDirectory.childFile('pubspec.yaml').path,
fileSystem: _fs,
logger: _logger,
);

Comment on lines +1220 to +1224
final FlutterManifest? flutterManifest = FlutterManifest.createFromPath(
projectDirectory.childFile('pubspec.yaml').path,
fileSystem: _fs,
logger: logger,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Parsing pubspec.yaml on every call to generateHeader (or _generateFile) is inefficient and performs I/O inside a string-formatting method. Consider parsing the dependencies once (e.g., lazily or during initialization) and caching the result in a private field of LocalizationsGenerator.

@bkonyi
bkonyi marked this pull request as draft October 15, 2026 21:47
@flutter-dashboard

Copy link
Copy Markdown

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gen-l10n should support Standalone UI packages

1 participant