Skip to content

Improve developer experience for opting in to Material 3 #105578

@guidezpl

Description

@guidezpl

Setting useMaterial3 applies certain defaults when constructed from the factory constructor, but since many themes are constructed from a default and customized with copyWith, they won't have correct typography or ripple effects. The code snippet below illustrates the missing defaults:

Copying my initial comment from a PR:

I would expect copyWith with useMaterial3 true to apply these updates, if I haven't provided my own typography and splashFactory, of course. If I understand correctly, we're currently requiring every created theme out there (that doesn't use the factory constructor) to add the following?

...
typography: Typography.material2021(platform: platform),
splashFactory: platform == TargetPlatform.android && !kIsWeb ? InkSparkle.splashFactory ?  InkRipple.splashFactory,
)

It's not documented anywhere and is pretty brittle.

Originally posted by @guidezpl in #104815 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions