Skip to content

Allow Passing an AnimationController to CircularProgressIndicator (Fix #165741) #170380

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
wants to merge 31 commits into
base: master
Choose a base branch
from

Conversation

Sten435
Copy link

@Sten435 Sten435 commented Jun 10, 2025

Pull request for issue: #165741
I also added support, to use an inherited controller, using the controller prop in progress_indicator_theme.dart.

fix.progress.indic.mp4

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • 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
  • All existing and new tests are passing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Jun 10, 2025
@dkwingsmt dkwingsmt self-requested a review June 10, 2025 20:19
@Sten435
Copy link
Author

Sten435 commented Jun 10, 2025

Shit i merged into main, i will change it to master.

👍 Fixed ✅

@Sten435 Sten435 changed the base branch from main to master June 10, 2025 21:33
@stan-at-work
Copy link

stan-at-work commented Jun 11, 2025

@dkwingsmt The Linux analyze check fails, when i look into the docs this is what it say's:

You may find the errors by searching for "╡ERROR #" in the logs.
╔═╡ERROR #1╞════════════════════════════════════════════════════════════════════
║ Command: dart --enable-asserts /b/s/w/ir/x/w/flutter/dev/bots/analyze.dart
║ Command exited with exit code 1 but expected zero exit code.
║ Working directory: /b/s/w/ir/x/w/flutter
╚═══════════════════════════════════════════════════════════════════════════════
▌23:20:10▐ Test failed.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The error messages reported above are repeated here:
  -- This line intentionally left blank --  
Command: dart --enable-asserts /b/s/w/ir/x/w/flutter/dev/bots/analyze.dart
Command exited with exit code 1 but expected zero exit code.
Working directory: /b/s/w/ir/x/w/flutter

image

This is not something I changed with my pull request. Does that mean this is not an issue for me, or what should I do to address it?

@dkwingsmt
Copy link
Contributor

If you click the detail link and see the full log (https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8712382049978374001/+/u/run_test.dart_for_analyze_shard_and_subshard_None/stdout?format=raw ) you'll find an error at ~45% of the file. I think it's just the eol space. Anyway, such errors can typically be solved by dart format packages/flutter.

@stan-at-work
Copy link

If you click the detail link and see the full log (https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8712382049978374001/+/u/run_test.dart_for_analyze_shard_and_subshard_None/stdout?format=raw ) you'll find an error at ~45% of the file. I think it's just the eol space. Anyway, such errors can typically be solved by dart format packages/flutter.

O thanks, don't know how you figured that out, from the logs. But thanks.

When i have access to my pc i will update the pull req ✅

@dkwingsmt
Copy link
Contributor

dkwingsmt commented Jun 11, 2025

image
The full log is here :) Yeah it can be a bit hidden

@Sten435
Copy link
Author

Sten435 commented Jun 11, 2025

If you click the detail link and see the full log (https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8712382049978374001/+/u/run_test.dart_for_analyze_shard_and_subshard_None/stdout?format=raw ) you'll find an error at ~45% of the file. I think it's just the eol space. Anyway, such errors can typically be solved by dart format packages/flutter.

You were indeed right, I ran the command you provided and what happend.... 1 change... 🥳

Screenshot 2025-06-11 at 20 45 51

@stan-at-work
Copy link

stan-at-work commented Jun 13, 2025

@dkwingsmt Does this pull request fall into the category of pull requests that the team will not merge until they have figured the Material and Cupertino styling out? I heard that something like that was going on at the moment.

Otherwise, I will close this pull request, and reopen it in a couple of months.

Thanks. 😃

@dkwingsmt
Copy link
Contributor

Hi! I don't think so. Although I'm currently on vacation and will review your PR when I'm back next week.

Also if there were such cases we would definitely tell the author right away instead of having you suspecting. :)

@stan-at-work
Copy link

Hi! I don't think so. Although I'm currently on vacation and will review your PR when I'm back next week.

Also if there were such cases we would definitely tell the author right away instead of having you suspecting. :)

I'm sorry thanks,

Have a nice vacation ☀️🌊

@dkwingsmt
Copy link
Contributor

Yep I've tested that adding disposal statements resolve the failure. 7a7da01

@stan-at-work
Copy link

Yep I've tested that adding disposal statements resolve the failure. 7a7da01

Thanks a lot for the feedback; I'll get those code comments adjusted. Thanks 👍

@@ -567,6 +567,80 @@ void main() {
expect(tester.binding.transientCallbackCount, 0);
});

testWidgets('LinearProgressIndicator reflects controller value', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the point of both tests. The controller's value is passed into the progress indicator directly?

Copy link
Contributor

Choose a reason for hiding this comment

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

The PR is adding a new property that increases the API surface. Tests should check that that property is respected (for both progress indicators and ProgressIndicatorThemeData as well.).

Copy link
Author

Choose a reason for hiding this comment

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

In what way should I check that its respected ?
Like check if the hashcode is the same or ?

Copy link
Author

Choose a reason for hiding this comment

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

I don't see the point of both tests. The controller's value is passed into the progress indicator directly?

Any idea's on how you would tackle this, differently ?

Copy link
Author

Choose a reason for hiding this comment

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

@dkwingsmt What do you think about this ?

Copy link
Contributor

Choose a reason for hiding this comment

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

One example I can think of is passing the same animation controller into multiple progress indicators on the same page and verifying at certain points they all have the same value?

Choose a reason for hiding this comment

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

This can't be done because everything is private in the class.
And there is no way to access private proprties, not even in tests...

Copy link
Contributor

Choose a reason for hiding this comment

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

This can't be done because everything is private in the class.

Testing in the framework focuses on observable behavior, not implementation details.

In progress_indicator_test.dart, there are tests that check what is painted by the progress indicators. A good test could have multiple progress indicators aligned in a Column, inserted at different times. Then some of them can have the same controller, and the ones with the same controller can be observed to have the same progress (i.e by the same paint extent, indicating a synchronized animation) while the others have a different paint extent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @Sten435, did you run into problems adding a test that fit the description in https://github.com/flutter/flutter/pull/170380/files#r2214098382?

@@ -567,6 +567,80 @@ void main() {
expect(tester.binding.transientCallbackCount, 0);
});

testWidgets('LinearProgressIndicator reflects controller value', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can't be done because everything is private in the class.

Testing in the framework focuses on observable behavior, not implementation details.

In progress_indicator_test.dart, there are tests that check what is painted by the progress indicators. A good test could have multiple progress indicators aligned in a Column, inserted at different times. Then some of them can have the same controller, and the ones with the same controller can be observed to have the same progress (i.e by the same paint extent, indicating a synchronized animation) while the others have a different paint extent.

@dkwingsmt
Copy link
Contributor

Hi! @Sten435 Are you able to address the comments above so we can work together to get this landed? This is a great addition and I'm looking forward to it!

@stan-at-work
Copy link

Hi! @Sten435 Are you able to address the comments above so we can work together to get this landed? This is a great addition and I'm looking forward to it!

👋 Yeah, I’ve tried a couple of things over the week, but none worked. I’m new to testing—definitely to animation testing—so I have to learn everything about widget testing. It’s taking some time, but I think I’ll get there.

@stan-at-work
Copy link

stan-at-work commented Jul 31, 2025

Hi! @Sten435 Are you able to address the comments above so we can work together to get this landed? This is a great addition and I'm looking forward to it!

I got the LinearProgressIndicator to work using a shared theming controller, but the CircularProgressIndicator is a whole other level to test.

Copy link
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

I'm beginning to wonder if this change is even needed. Why can't multiple progress indicators be supplied the same animation controller value directly in order to synchronize them? Do they need an entire AnimationController?

@dkwingsmt
Copy link
Contributor

dkwingsmt commented Aug 8, 2025

I think it's because it's a very common demand for progress indicators to stay in sync when multiple are present, so much that the widget is pretty much unusable if there isn't such a feature (i.e. all developers will have to build it by themselves.) The progress indicators are typically scattered across the widget tree and supplying values directly will cause the entire tree to be rebuilt every frame.

@stan-at-work
Copy link

I think it's because it's a very common demand for progress indicators to stay in sync when multiple are present, so much that the widget is pretty much unusable if there isn't such a feature (i.e. all developers will have to build it by themselves.) The progress indicators are typically scattered across the widget tree and supplying values directly will cause the entire tree to be rebuilt every frame.

I'm sorry for the delay. This will be done. But i'm verrry busy atm.

@dkwingsmt
Copy link
Contributor

dkwingsmt commented Aug 11, 2025

No worries, take you time!

Edit: If it makes you feel better, feel free to turn it into a draft or close it for now, and we can always come back to this.

@stan-at-work
Copy link

No worries, take you time!

Edit: If it makes you feel better, feel free to turn it into a draft or close it for now, and we can always come back to this.

No, i rather not close it.

@Sten435
Copy link
Author

Sten435 commented Aug 17, 2025

@dkwingsmt I have added a test, but after several days of effort, I was unable to create one for the circular progress indicator. This task is beyond my current experience with Flutter widget testing.

I invested considerable effort into the linear progress indicator test and managed to complete it, showing my commitment to delivering quality work. I have poured my heart and soul into this pull request. It may seem unusual, but I have learned a lot—and also suffered quite a bit—in the process. I don’t want to give up on this change, but I will not attempt a circular progress indicator test because I don’t want to drain myself further with Flutter widget tests.

I genuinely believe this change brings value and hope it can be merged. If the lack of this specific test prevents that, I understand, but I want to assure you that I have given my best effort. Sometimes, progress means recognizing the limits of what can reasonably be achieved while still giving your full effort.

It has been 148 days since I proposed this issue, and I have made my peace with the possibility that it may not be merged any time soon.

If the test is really needed, I accept that this pull request will be closed and hopefully picked up by someone else in the future. Hopefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants