Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@cyanglaz
Copy link
Contributor

This is a fix for flutter/flutter#21709

Creating a second instance of the Connectivity object can cause the second instance overriding the first instance's stream channel. We can force the class to be a singleton because this class is designed to work as a singleton.

@cyanglaz cyanglaz requested a review from mehmetf January 30, 2019 01:15
// EventChannel because it is overridden. Forcing the class to be a singleton class can prevent
// misusage of creating a second instance from a programmer.
factory Connectivity() {
return _singleton;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Let's initialize this lazily rather than eagerly.

@cyanglaz cyanglaz merged commit 06fd96e into flutter:master Jan 30, 2019
@cyanglaz cyanglaz deleted the connectivity_singleton branch January 30, 2019 18:03
andreidiaconu pushed a commit to andreidiaconu/plugins that referenced this pull request Feb 17, 2019
Fix for flutter/flutter#21709

Creating a second instance of the Connectivity object can cause the second instance overriding the first instance's stream channel. We can force the class to be a singleton because this class is designed to work as a singleton.
andreidiaconu added a commit to andreidiaconu/plugins that referenced this pull request Feb 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants