Vanethos / flutter_connectivity_widget

A widget that shows the user if the phone is connected to the internet or not
BSD 2-Clause "Simplified" License
68 stars 34 forks source link

ConnectivityUtils: Default values are getting overridden with null. #18

Closed colinmcintyre closed 1 year ago

colinmcintyre commented 4 years ago

19 Pull Request Sent

The default values within the ConnectivityUtils are getting overridden with NULL if initialize is called without values passed through. Also they will get overridden if instance is called and no instance exists.

` String _serverToPing = "http://www.gstatic.com/generate_204"; VerifyResponseCallback callback = () => true;

... static ConnectivityUtils initialize({String serverToPing, VerifyResponseCallback callback}) { instance = ConnectivityUtils.(serverToPing : serverToPing, callback : callback); return _instance; }

static ConnectivityUtils get instance { if (_instance == null) { instance = ConnectivityUtils.(); } return _instance; }

ConnectivityUtils._({String serverToPing, VerifyResponseCallback callback}) { // Change these two lines from: this._serverToPing = serverToPing; this._callback = callback; // TO: this._serverToPing = serverToPing != null ? serverToPing : this._serverToPing; this._callback = callback!= null ? callback: this._callback ; `

If not it forces the user to call the following all the time ConnectivityUtils.initialize(serverToPing: "http://www.gstatic.com/generate_204", callback: (_) => true);

Vanethos commented 4 years ago

Closed via #19