Skip to content

Conversation

@darrenaustin
Copy link
Contributor

To make the common button .styleFrom methods a little easier to use, this PR adds the following parameters to each of ElevatedButton.styleFrom, OutlinedButton.styleFrom and TextButton.styleFrom:

    Color? foregroundColor,
    Color? backgroundColor,
    Color? disabledForegroundColor,
    Color? disabledBackgroundColor,

If given they will be used to construct foreground and background MaterialStateProperty colors for the style. These replace primary, onPrimary, and onSurface which are deprecated.

To update your apps to use these new parameters you can either use the quick fix feature of your IDE, or use Flutter Fix to apply the given fixes to your entire project.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos documentation f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. c: tech-debt Technical debt, code quality, testing, etc. labels Jun 3, 2022
@darrenaustin
Copy link
Contributor Author

This will require #105290 to land first, as the deprecation versions are now using beta releases, not dev releases.

Copy link
Member

@guidezpl guidezpl left a comment

Choose a reason for hiding this comment

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

This is clean.

  _    ___ _____ __  __ 
 | |  / __|_   _|  \/  |
 | |_| (_ | | | | |\/| |
 |____\___| |_| |_|  |_|
                        

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

LGTM

darrenaustin added a commit to darrenaustin/plugins that referenced this pull request Jun 9, 2022
darrenaustin added a commit to darrenaustin/plugins that referenced this pull request Jun 10, 2022
darrenaustin added a commit to darrenaustin/plugins that referenced this pull request Jun 13, 2022
darrenaustin added a commit to darrenaustin/plugins that referenced this pull request Jun 15, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 22, 2022
@bwilkerson
Copy link
Contributor

This PR appears to have broken the flutter-analyze bot on the Dart build system. Based on the log output:

Analyzing gallery...

   info - lib/pages/demo.dart:823:15 - 'primary' is deprecated and shouldn't be used. Use backgroundColor instead. This feature was deprecated after v3.1.0.. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use
   info - lib/studies/rally/finance.dart:122:41 - 'primary' is deprecated and shouldn't be used. Use foregroundColor instead. This feature was deprecated after v3.1.0.. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use
   info - lib/studies/rally/finance.dart:385:9 - 'primary' is deprecated and shouldn't be used. Use foregroundColor instead. This feature was deprecated after v3.1.0.. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use
   info - lib/studies/rally/login.dart:380:9 - 'primary' is deprecated and shouldn't be used. Use foregroundColor instead. This feature was deprecated after v3.1.0.. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use
   info - lib/studies/rally/login.dart:406:9 - 'primary' is deprecated and shouldn't be used. Use foregroundColor instead. This feature was deprecated after v3.1.0.. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use
   info - lib/studies/rally/tabs/overview.dart:175:51 - 'primary' is deprecated and shouldn't be used. Use foregroundColor instead. This feature was deprecated after v3.1.0.. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use
   info - lib/studies/rally/tabs/overview.dart:281:43 - 'primary' is deprecated and shouldn't be used. Use foregroundColor instead. This feature was deprecated after v3.1.0.. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use
   info - lib/studies/rally/tabs/settings.dart:53:9 - 'primary' is deprecated and shouldn't be used. Use foregroundColor instead. This feature was deprecated after v3.1.0.. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use
   info - lib/studies/shrine/shopping_cart.dart:110:25 - 'primary' is deprecated and shouldn't be used. Use backgroundColor instead. This feature was deprecated after v3.1.0.. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use

it appears that the flutter gallery app is still using primary and needs to be updated.

This suggests that the flutter gallery app is not being analyzed as part of the build process, which might indicate a different kind of issue.

@guidezpl
Copy link
Member

You may want use pinning to allow fixes for changes such as this to get in without breaking builds. See also https://github.com/flutter/gallery#tests.

@bwilkerson
Copy link
Contributor

@athomas for the previous comment.

@athomas
Copy link
Contributor

athomas commented Jun 26, 2022

The point of the multi headed testing is to detect problems before the rolls, and pinning would defeat that.

@Hixie
Copy link
Contributor

Hixie commented Jul 26, 2022

Looks like some of the API docs still refer to primary et al. I've filed #108333 to track this.

camsim99 pushed a commit to camsim99/flutter that referenced this pull request Aug 10, 2022
* Update parameters to the `styleFrom` button methods.

* Updated the Flutter fix data to point to this PR.

* Updated handling of background color to better maintain backwards compatibility with previous API.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 30, 2022
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Dec 5, 2023
…s from `ElevatedButton.styleFrom` (#5566)

This PR is to remove deprecated `primary` and `onPrimary` references([deprecation PR](flutter/flutter#105291)) from `ElevatedButton.styleFrom`.

`primary` should be replaced with `backgroundColor` and `onPrimary` should be replaced with `foregroundColor`.

No new tests needed. Please let me know if I incorrectly handled the CHANGELOG and version change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems c: contributor-productivity Team-specific productivity, code health, technical debt. c: tech-debt Technical debt, code quality, testing, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants