Repository navigation
Clarify MaterialButton usage and documentation #98693
Description
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
Piinks commentedon 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 commentedon 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.
rydmike commentedon Feb 24, 2022
Agreed, after removing the deprecated buttons,
MaterialButtonis 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
MaterialButtonis imo not so useful as a raw button building block. TheRawMaterialbuttonfills that role better and is used for it in the SDK too. Although only byFloatingActionButtonandToggleButtons, so not so much. Still it is a useful building block for custom buttons.As a reminder,
MaterialButtonis also referenced in a large number of getters in itsButtonThemeData, where you pass several different getters aMaterialButtonand it contains things e.g. like this:Where
MaterialButtonand in above example case all the deprecated buttons are referenced too. So to removeMaterialButton',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
ThemeDataclean 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 commentedon Feb 24, 2022
This is going to be deprecated, will sync with @TahaTesser's work first
Piinks commentedon 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.