Skip to content

Conversation

@rkishan516
Copy link
Contributor

Feat: Add withOpacity to gradient because sometimes it's required to call withOpacity directly on gradient

Resolves #150501

This adds a withOpacity feature to a gradient, given user has given colors this will override opacity to given opacity for them.

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].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Jun 23, 2024
@jonahwilliams
Copy link
Contributor

Approach seems reasonable, you have some analysis errors:

   info • Type could be non-nullable • packages/flutter/test/painting/gradient_test.dart:319:27 • unnecessary_nullable_for_final_variable_declarations
   info • Type could be non-nullable • packages/flutter/test/painting/gradient_test.dart:635:27 • unnecessary_nullable_for_final_variable_declarations
   info • Type could be non-nullable • packages/flutter/test/painting/gradient_test.dart:869:26 • unnecessary_nullable_for_final_variable_declarations

@rkishan516 rkishan516 force-pushed the gradient_with_opacity branch from 401b62b to 781a51e Compare June 25, 2024 15:51
@rkishan516 rkishan516 force-pushed the gradient_with_opacity branch from 846548d to 0a79e38 Compare June 25, 2024 15:55
@rkishan516
Copy link
Contributor Author

@jonahwilliams I have updated based on your suggestion

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@rkishan516
Copy link
Contributor Author

Thanks @jonahwilliams

Copy link
Contributor

@nate-thegrate nate-thegrate left a comment

Choose a reason for hiding this comment

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

LGTM, aside from documentation :)

Copy link
Contributor

@nate-thegrate nate-thegrate left a comment

Choose a reason for hiding this comment

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

This looks fantastic, thank you!

I'll go ahead and delete the extra character, and then I think we're good to merge 👍

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jul 7, 2024
Roll Flutter from af913a7 to fafd67d (41 revisions)

flutter/flutter@af913a7...fafd67d

2024-07-05 engine-flutter-autoroll@skia.org Roll Flutter Engine from 74d40c160e48 to 4ee09d3b7f3b (1 revision) (flutter/flutter#151346)
2024-07-05 engine-flutter-autoroll@skia.org Roll Flutter Engine from ba9c7b6336ef to 74d40c160e48 (1 revision) (flutter/flutter#151340)
2024-07-05 engine-flutter-autoroll@skia.org Roll Flutter Engine from 1f0f950ea02a to ba9c7b6336ef (1 revision) (flutter/flutter#151331)
2024-07-05 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3c6a373bda3e to 1f0f950ea02a (1 revision) (flutter/flutter#151326)
2024-07-04 engine-flutter-autoroll@skia.org Roll Flutter Engine from 79a91e38c587 to 3c6a373bda3e (2 revisions) (flutter/flutter#151318)
2024-07-04 engine-flutter-autoroll@skia.org Roll Packages from d2705fb to 754de19 (3 revisions) (flutter/flutter#151315)
2024-07-04 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2b6bb516e7e6 to 79a91e38c587 (2 revisions) (flutter/flutter#151314)
2024-07-04 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8e2d05fa95d7 to 2b6bb516e7e6 (2 revisions) (flutter/flutter#151299)
2024-07-04 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4190543cb093 to 8e2d05fa95d7 (13 revisions) (flutter/flutter#151293)
2024-07-03 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#151203)
2024-07-03 Dispersia@users.noreply.github.com Fix invalid URL suggestion for gradle incompatability (flutter/flutter#150999)
2024-07-03 423393+veloce@users.noreply.github.com Cupertino transparent navigation bars (flutter/flutter#149102)
2024-07-03 1961493+harryterkelsen@users.noreply.github.com Prepares semantics_update_test for upcoming link URL change (flutter/flutter#151261)
2024-07-03 nate.w5687@gmail.com Add a message about spam/brigading (flutter/flutter#150583)
2024-07-03 hans.muller@gmail.com PinnedHeaderSliver example based on the iOS Settings AppBar (flutter/flutter#151205)
2024-07-03 katelovett@google.com Update deprecation policy (flutter/flutter#151257)
2024-07-03 hans.muller@gmail.com SliverFloatingHeader (flutter/flutter#151145)
2024-07-03 34871572+gmackall@users.noreply.github.com Remove warning when KGP version not detected (flutter/flutter#151254)
2024-07-03 34465683+rkishan516@users.noreply.github.com Feat: Add withOpacity to gradient (flutter/flutter#150670)
2024-07-03 goderbauer@google.com Fix references in examples (flutter/flutter#151204)
2024-07-03 82763757+NobodyForNothing@users.noreply.github.com Fix link in tree hygene doc (flutter/flutter#151235)
2024-07-03 yinxulolol@gmail.com content dimensions are not established get controller value error (flutter/flutter#148938)
2024-07-03 michaleli@foxmail.com chore: fix typos and link broken (flutter/flutter#150402)
2024-07-03 dev@alestiago.com Add example of goldenFileComparator usage in widget tests (flutter/flutter#150422)
2024-07-03 brackenavaron@gmail.com Fix project name fallback (flutter/flutter#150614)
2024-07-03 engine-flutter-autoroll@skia.org Roll Flutter Engine from a3e61c0fd1c2 to 4190543cb093 (1 revision) (flutter/flutter#151241)
2024-07-03 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8274f54f11be to a3e61c0fd1c2 (2 revisions) (flutter/flutter#151237)
2024-07-03 jason-simmons@users.noreply.github.com Force regeneration of platform-specific manifests before running performance tests (flutter/flutter#151003)
2024-07-03 jason-simmons@users.noreply.github.com Handle a SocketException thrown when sending the browser close command to Chrome (flutter/flutter#151197)
2024-07-03 engine-flutter-autoroll@skia.org Roll Flutter Engine from a02e3f673da3 to 8274f54f11be (4 revisions) (flutter/flutter#151226)
2024-07-03 engine-flutter-autoroll@skia.org Roll Flutter Engine from c5c0c54d6d1d to a02e3f673da3 (1 revision) (flutter/flutter#151212)
2024-07-03 engine-flutter-autoroll@skia.org Roll Flutter Engine from 44278941443e to c5c0c54d6d1d (9 revisions) (flutter/flutter#151208)
2024-07-02 jon@jon.sg Fix scheduler event loop being stuck due to task with Priority.idle (flutter/flutter#151168)
2024-07-02 matej.knopp@gmail.com Fix result propagation in RenderSliverEdgeInsetsPadding.hitTestChildren (flutter/flutter#149825)
2024-07-02 goderbauer@google.com docImports for flutter_test (flutter/flutter#151189)
2024-07-02 Michal-MK@users.noreply.github.com Interactable ScrollView content when settling a scroll activity (flutter/flutter#145848)
2024-07-02 danny@tuppeny.com [flutter_tools] Update the mapping for the Dart SDK internal URI (flutter/flutter#151170)
2024-07-02 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#151129)
2024-07-02 36861262+QuncCccccc@users.noreply.github.com Fix typo (flutter/flutter#151192)
2024-07-02 andrewrkolos@gmail.com [tool] Fix `stdin.flush` calls on processes started by `FakeProcessManager` (flutter/flutter#151183)
2024-07-02 engine-flutter-autoroll@skia.org Roll Flutter Engine from 433d360eee11 to 44278941443e (4 revisions) (flutter/flutter#151186)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC camillesimon@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
...
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request Jul 8, 2024
Feat: Add withOpacity to gradient because sometimes it's required to call withOpacity directly on gradient

Resolves flutter#150501 

This adds a `withOpacity` feature to a gradient, given user has given colors this will override opacity to given opacity for them.
@rkishan516 rkishan516 deleted the gradient_with_opacity branch July 26, 2025 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gradient withOpacity method

4 participants