Skip to content

Clarify MaterialButton usage and documentation #98693

Open

Description

@Piinks

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

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    d: api docsIssues with https://api.flutter.dev/
    a: qualityA truly polished experience
    a: annoyanceRepeatedly frustrating issues with non-experimental functionality
    P2Important issues not at the top of the work list
    on Feb 17, 2022
  2. Piinks commented on Feb 17, 2022

    @Piinks
    ContributorAuthor

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

  3. Piinks commented on Feb 23, 2022

    @Piinks
    ContributorAuthor

    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.

  4. self-assigned this
    on Feb 23, 2022
  5. rydmike commented on Feb 24, 2022

    @rydmike
    Contributor

    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.

  6. Piinks commented on Feb 24, 2022

    @Piinks
    ContributorAuthor

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

  7. Piinks commented on Feb 24, 2022

    @Piinks
    ContributorAuthor

    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.

  8. removed their assignment
    on Feb 24, 2022
  9. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: annoyanceRepeatedly frustrating issues with non-experimental functionalitya: qualityA truly polished experienced: api docsIssues with https://api.flutter.dev/p: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions