Thanks to visit codestin.com
Credit goes to github.com

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

[connectivity] announce 1.0, deprecate wifi APIs #3183

Merged
merged 8 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/connectivity/connectivity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.0

* Mark wifi related code deprecated.
* Announce 1.0.0!

## 0.4.9+5

* Update android compileSdkVersion to 29.
Expand Down
11 changes: 11 additions & 0 deletions packages/connectivity/connectivity/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,23 @@ class _MyHomePageState extends State<MyHomePage> {
try {
if (!kIsWeb && Platform.isIOS) {
LocationAuthorizationStatus status =
// ignore: deprecated_member_use
await _connectivity.getLocationServiceAuthorization();
if (status == LocationAuthorizationStatus.notDetermined) {
status =
// ignore: deprecated_member_use
await _connectivity.requestLocationServiceAuthorization();
}
if (status == LocationAuthorizationStatus.authorizedAlways ||
status == LocationAuthorizationStatus.authorizedWhenInUse) {
// ignore: deprecated_member_use
wifiName = await _connectivity.getWifiName();
} else {
// ignore: deprecated_member_use
wifiName = await _connectivity.getWifiName();
}
} else {
// ignore: deprecated_member_use
wifiName = await _connectivity.getWifiName();
}
} on PlatformException catch (e) {
Expand All @@ -127,18 +132,23 @@ class _MyHomePageState extends State<MyHomePage> {
try {
if (!kIsWeb && Platform.isIOS) {
LocationAuthorizationStatus status =
// ignore: deprecated_member_use
await _connectivity.getLocationServiceAuthorization();
if (status == LocationAuthorizationStatus.notDetermined) {
status =
// ignore: deprecated_member_use
await _connectivity.requestLocationServiceAuthorization();
}
if (status == LocationAuthorizationStatus.authorizedAlways ||
status == LocationAuthorizationStatus.authorizedWhenInUse) {
// ignore: deprecated_member_use
wifiBSSID = await _connectivity.getWifiBSSID();
} else {
// ignore: deprecated_member_use
wifiBSSID = await _connectivity.getWifiBSSID();
}
} else {
// ignore: deprecated_member_use
wifiBSSID = await _connectivity.getWifiBSSID();
}
} on PlatformException catch (e) {
Expand All @@ -147,6 +157,7 @@ class _MyHomePageState extends State<MyHomePage> {
}

try {
// ignore: deprecated_member_use
wifiIP = await _connectivity.getWifiIP();
} on PlatformException catch (e) {
print(e.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ void main() {
expect(result, isNotNull);
switch (result) {
case ConnectivityResult.wifi:
// ignore: deprecated_member_use
expect(_connectivity.getWifiName(), completes);
// ignore: deprecated_member_use
expect(_connectivity.getWifiBSSID(), completes);
// ignore: deprecated_member_use
expect((await _connectivity.getWifiIP()), isNotNull);
break;
default:
Expand All @@ -33,6 +36,7 @@ void main() {

testWidgets('test location methods, iOS only', (WidgetTester tester) async {
if (Platform.isIOS) {
// ignore: deprecated_member_use
expect((await _connectivity.getLocationServiceAuthorization()),
LocationAuthorizationStatus.notDetermined);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ void main() {
expect(result, isNotNull);
switch (result) {
case ConnectivityResult.wifi:
// ignore: deprecated_member_use_from_same_package
expect(_connectivity.getWifiName(), completes);
// ignore: deprecated_member_use_from_same_package
expect(_connectivity.getWifiBSSID(), completes);
// ignore: deprecated_member_use_from_same_package
expect((await _connectivity.getWifiIP()), isNotNull);
break;
default:
Expand All @@ -33,6 +36,7 @@ void main() {

testWidgets('test location methods, iOS only', (WidgetTester tester) async {
if (Platform.isIOS) {
// ignore: deprecated_member_use_from_same_package
expect((await _connectivity.getLocationServiceAuthorization()),
LocationAuthorizationStatus.notDetermined);
}
Expand Down
10 changes: 10 additions & 0 deletions packages/connectivity/connectivity/lib/connectivity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class Connectivity {
///
/// From android 8.0 onwards the GPS must be ON (high accuracy)
/// in order to be able to obtain the SSID.
@Deprecated(
'This method is deprecated. Please use wifi_info_flutter instead. See https://github.com/flutter/plugins/blob/master/packages/wifi_info_flutter/wifi_info_flutter/README.md')
Future<String> getWifiName() {
return _platform.getWifiName();
}
Expand All @@ -63,11 +65,15 @@ class Connectivity {
///
/// From Android 8.0 onwards the GPS must be ON (high accuracy)
/// in order to be able to obtain the BSSID.
@Deprecated(
'This method is deprecated. Please use wifi_info_flutter instead. See https://github.com/flutter/plugins/blob/master/packages/wifi_info_flutter/wifi_info_flutter/README.md')
Copy link
Member

Choose a reason for hiding this comment

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

Why not a link to pub.dev? It'd be much shorter!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wifi_info_flutter is not published yet :(

Future<String> getWifiBSSID() {
return _platform.getWifiBSSID();
}

/// Obtains the IP address of the connected wifi network
@Deprecated(
'This method is deprecated. Please use wifi_info_flutter instead. See https://github.com/flutter/plugins/blob/master/packages/wifi_info_flutter/wifi_info_flutter/README.md')
Future<String> getWifiIP() {
return _platform.getWifiIP();
}
Expand Down Expand Up @@ -120,6 +126,8 @@ class Connectivity {
/// Ideally, a location service authorization should only be requested if the current authorization status is not determined.
///
/// See also [getLocationServiceAuthorization] to obtain current location service status.
@Deprecated(
'This method is deprecated. Please use wifi_info_flutter instead. See https://github.com/flutter/plugins/blob/master/packages/wifi_info_flutter/wifi_info_flutter/README.md')
Future<LocationAuthorizationStatus> requestLocationServiceAuthorization({
bool requestAlwaysLocationUsage = false,
}) {
Expand Down Expand Up @@ -164,6 +172,8 @@ class Connectivity {
/// ```
///
/// See also [requestLocationServiceAuthorization] for requesting a location service authorization.
@Deprecated(
'This method is deprecated. Please use wifi_info_flutter instead. See https://github.com/flutter/plugins/blob/master/packages/wifi_info_flutter/wifi_info_flutter/README.md')
Future<LocationAuthorizationStatus> getLocationServiceAuthorization() {
return _platform.getLocationServiceAuthorization();
}
Expand Down
5 changes: 1 addition & 4 deletions packages/connectivity/connectivity/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ name: connectivity
description: Flutter plugin for discovering the state of the network (WiFi &
mobile/cellular) connectivity on Android and iOS.
homepage: https://github.com/flutter/plugins/tree/master/packages/connectivity/connectivity
# 0.4.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.4.9+5
version: 1.0.0

flutter:
plugin:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,33 @@ void main() {
});

test('getWifiName', () async {
// ignore: deprecated_member_use_from_same_package
String result = await connectivity.getWifiName();
expect(result, kWifiNameResult);
});

test('getWifiBSSID', () async {
// ignore: deprecated_member_use_from_same_package
String result = await connectivity.getWifiBSSID();
expect(result, kWifiBSSIDResult);
});

test('getWifiIP', () async {
// ignore: deprecated_member_use_from_same_package
String result = await connectivity.getWifiIP();
expect(result, kWifiIpAddressResult);
});

test('requestLocationServiceAuthorization', () async {
LocationAuthorizationStatus result =
// ignore: deprecated_member_use_from_same_package
await connectivity.requestLocationServiceAuthorization();
expect(result, kRequestLocationResult);
});

test('getLocationServiceAuthorization', () async {
LocationAuthorizationStatus result =
// ignore: deprecated_member_use_from_same_package
await connectivity.getLocationServiceAuthorization();
expect(result, kRequestLocationResult);
});
Expand Down