Skip to content

Clarify MaterialButton usage and documentation #98693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Piinks opened this issue Feb 17, 2022 · 5 comments
Open

Clarify MaterialButton usage and documentation #98693

Piinks opened this issue Feb 17, 2022 · 5 comments
Labels
a: annoyance Repeatedly frustrating issues with non-experimental functionality a: quality A truly polished experience d: api docs Issues with https://api.flutter.dev/ f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@Piinks
Copy link
Contributor

Piinks commented Feb 17, 2022

From @rydmike in #98537 (comment)

MaterialButton

Next comes the question of the fate of the MaterialButton the parent class for the buttons to be removed.

It is also in the docs marked as obsolete but not deprecated.

/// ### This class is obsolete.

Will it remain available or be removed? My conclusion is, it will stay, even if it does not correctly implement or enable users to create Material buttons, plus its children will be gone due to same reasons. Considering this, it seems a bit illogical for it to remain, but it would be difficult to remove without a number of other changes discussed further below.

My search did no reveal any other usages and mentions of MaterialButton than in its child buttons that will be removed, and in ButtonThemeData itself, in a large number of odd looking getters.


Removed quoted section here as a separate issue: #98692


The fact that ButtonThemeData, that needs to remain for ButtonBar and DropdownButton, itself depends on MaterialButton, also makes it impossible to remove the "obsolete" MaterialButton parent of all the 3 buttons now being removed.

In Material there is in the MaterialType enum a doc comment to MaterialButton in enum value button.

/// Rounded edges, no color by default (used for [MaterialButton] buttons).

So I checked for references to MaterialType.button, other than in Material it is only used by RawMatererialButton and ButtonStyleButton. maybe consider updating the above doc ref to them instead of MaterialButton.

If the MaterialButton is considered and marked as obsolete in the docs, which imo is correct, thus maybe consider deprecating it and plan for changes need to be able to remove it.


Similar to #98691, obsolete is not a term folks know what to do with. What does it mean when other parts of the framework still depend on it? Some guidance would be helpful to add. cc @HansMuller & @darrenaustin

@Piinks Piinks added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. d: api docs Issues with https://api.flutter.dev/ a: quality A truly polished experience documentation a: annoyance Repeatedly frustrating issues with non-experimental functionality P2 Important issues not at the top of the work list labels Feb 17, 2022
@Piinks
Copy link
Contributor Author

Piinks commented Feb 17, 2022

If this is just planned to be removed eventually, see full linked comment above, just that would be a beneficial bit of guidance.

@Piinks
Copy link
Contributor Author

Piinks commented Feb 23, 2022

From what I can tell, while there are no more uses of MaterialButton in the framework (after removing the deprecated buttons - Flat, Raised, and Outline), there are still a lot of customers that use it - a lot.

A MaterialButton just basically creates a RawMaterialButton, but the big difference is the former supports inherited themes while the later does not. I think the mention of the old button should be removed from the docs, as well as the "this is obsolete" distinction to avoid confusion.

Since this is still a heavily used widget, I think the docs should just focus on the use cases with theming in contrast to the Raw one - rather than how this widget used to be used. It affords folks a totally customizable - and theme-able - button, in contrast to the already configured Text, Elevated and Outlined buttons.

@Piinks Piinks self-assigned this Feb 23, 2022
@rydmike
Copy link
Contributor

rydmike commented Feb 24, 2022

Agreed, after removing the deprecated buttons, MaterialButton is no longer actively used or very useful in the framework. However, I'm sure there are still many customer projects that use it for various purposes, so there is always that to consider too.

The MaterialButton is imo not so useful as a raw button building block. The RawMaterialbutton fills that role better and is used for it in the SDK too. Although only by FloatingActionButton and ToggleButtons, so not so much. Still it is a useful building block for custom buttons.

As a reminder, MaterialButton is also referenced in a large number of getters in its ButtonThemeData, where you pass several different getters a MaterialButton and it contains things e.g. like this:

  Color getSplashColor(MaterialButton button) {
    if (button.splashColor != null)
      return button.splashColor!;

    if (_splashColor != null && (button is RaisedButton || button is OutlineButton))
      return _splashColor!;

    if (_splashColor != null && button is FlatButton) {
      switch (getTextTheme(button)) {
        case ButtonTextTheme.normal:
        case ButtonTextTheme.accent:
          return _splashColor!;
        case ButtonTextTheme.primary:
          break;
      }
    }

    return getTextColor(button).withOpacity(0.12);
  }

Where MaterialButton and in above example case all the deprecated buttons are referenced too. So to remove MaterialButton', FlatButton,RaisedButton, OutlineButtoncompletely, theButtonThemeData` class has to be modified quite a bit, or also removed.

I think it's deprecation and removal is on the roadmap now too, mentioned at least in this comment #53378 (comment), but I did not see an issue issue on it yet. If it exists, it might be good to add to the ThemeData clean up collection #91772 and/or at least here #98691.

In any case complete removal of the classes for the deprecated buttons cannot happen unless it is also in sync with needed changes to ButtonThemeData, if it needs to remain a bit longer, or its complete removal.

@Piinks
Copy link
Contributor Author

Piinks commented Feb 24, 2022

This is going to be deprecated, will sync with @TahaTesser's work first

@Piinks
Copy link
Contributor Author

Piinks commented Feb 24, 2022

Had a sync with @TahaTesser, I am un-assigning myself from this currently to go focus on refactoring FAB (#99086) to remove dependencies there in order to make removing this class in the future possible.

@Piinks Piinks removed their assignment Feb 24, 2022
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: annoyance Repeatedly frustrating issues with non-experimental functionality a: quality A truly polished experience d: api docs Issues with https://api.flutter.dev/ f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy