Skip to content

[material_ui] Set up m3e_gen_defaults sub-directory#11762

Open
elliette wants to merge 2 commits into
flutter:m3e_migrationfrom
elliette:gen-defaults-impl-2
Open

[material_ui] Set up m3e_gen_defaults sub-directory#11762
elliette wants to merge 2 commits into
flutter:m3e_migrationfrom
elliette:gen-defaults-impl-2

Conversation

@elliette
Copy link
Copy Markdown
Member

Work towards flutter/flutter#186906

Adds the initial gen_defaults sub-directory with the initial TokenTemplate and generator. This is simply the initial scaffold, we will need to add additional helper functions as necessary as we begin adding the actual templates.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 22, 2026
@github-actions github-actions Bot added triage-framework Should be looked at in framework triage p: material_ui labels May 22, 2026
@elliette elliette requested a review from QuncCccccc May 22, 2026 17:17
Copy link
Copy Markdown

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

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 a new 'Token Defaults Generator' tool in the material_ui package, consisting of a command-line script, a base template class for code generation, and unit tests. Review feedback identifies a discrepancy between the documented and implemented output paths, a typo in the SDK version constraint which is incompatible with the workspace resolution feature, and a potential runtime error when creating files in non-existent directories.

Comment thread packages/material_ui/tool/m3e_gen_defaults/templates/template.dart
Comment thread packages/material_ui/tool/m3e_gen_defaults/pubspec.yaml
Comment thread packages/material_ui/tool/m3e_gen_defaults/templates/template.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label May 22, 2026
@QuncCccccc
Copy link
Copy Markdown
Contributor

Do you think whether naming the folder gen_defaults would be better? Since currently the tokens we exported here also include M3 widget tokens, the new gen_defaults could be used for M3 token update (if needed).

Copy link
Copy Markdown
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

Overall LGTM! Just left some comments.

version: 1.0.0

environment:
sdk: ^3.10.0-0
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.

I'm actually not familiar with how to constrain the version. In packages/material_ui/pubspec.yaml, it shows sdk: ^3.9.0, do we need to match it?

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.

oh but seems material_ui/example also use sdk: ^3.10.0-0

@@ -0,0 +1,15 @@
name: gen_defaults
description: A command line script to generate Material component defaults from the token database.
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.

Should we also make it not publishable? like material_ui/example.

Suggested change
description: A command line script to generate Material component defaults from the token database.
description: A command line script to generate Material component defaults from the token database.
publish_to: none

```

This updates generated component theming files under
`packages/material_ui/lib/src/m3e/generated`.
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.

The new folder for m3e should not contain abbreviation based on the style guide.

Suggested change
`packages/material_ui/lib/src/m3e/generated`.
`packages/material_ui/lib/src/material_3_expressive/generated`.


String get materialLib {
const packagePath = 'packages/material_ui';
const relativeOutputPath = 'lib/src/m3e/generated';
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.

Suggested change
const relativeOutputPath = 'lib/src/m3e/generated';
const relativeOutputPath = 'lib/src/material_3_expressive/generated';

// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

abstract final class TokenButton {
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.

Just to match the real generated token file

Suggested change
abstract final class TokenButton {
class TokenButton {

// Design token database by the script:
// packages/material_ui/tool/m3e_gen_defaults/bin/gen_defaults.dart.

// dart format off
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.

Maybe we should remove this and keep the format correct, even though it's just generated code. I vaguely remember this line is added when we started to use dart format and wanted to avoid updating these code that are already generated. But for expressive, maybe we can consider to allow dart format?

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

Labels

p: material_ui triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants