Skip to content
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

Add new listener builder widget #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iamsahilsonawane
Copy link

Problem statement

Was wandering around this package. I saw there's just a widget builder widget rebuilding the widgets on change of the connectivity. I think it should have a widget that will just give me a listener, as I don't want to rebuild the widgets but do some action against the change.

Eg.: I want to show the users an alert if they switch to mobile data to shift back to wifi (as for instance I am downloading big files or streaming high-quality content)

Solution

I've implemented a new widget like that of the builder, but with a listenerBuilder property to just listen to changes and not rebuild the widgets.

Bonus

I've also added in listenWhen to only listen to specific changes. For more details, refer to the new demo page in the example.

Video Sample

Screenrecorder-2022-08-08-13-32-22-500.mp4

@nicks258
Copy link

nicks258 commented Apr 6, 2023

Thanks. I was looking for the same.

Copy link
Owner

@jogboms jogboms left a comment

Choose a reason for hiding this comment

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

Amazing contribution @iamsahilsonawane
Sorry for the long delay. I was absent from OSS work. I would love it if you are still willing to continue.

}

void _listenToChanges() {
_connectivityStream.listen((data) {
Copy link
Owner

Choose a reason for hiding this comment

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

Can you dispose of this subscription?


@override
Widget build(BuildContext context) {
return OfflineListener(
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add this to the README?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants