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

[WIP] fix(canvas): request local network before connect to device #1647

Merged
merged 9 commits into from
May 15, 2024
3 changes: 2 additions & 1 deletion lib/service/canvas_client_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:autonomy_flutter/model/shared_postcard.dart';
import 'package:autonomy_flutter/screen/detail/preview/canvas_device_bloc.dart';
import 'package:autonomy_flutter/service/account_service.dart';
import 'package:autonomy_flutter/service/navigation_service.dart';
import 'package:autonomy_flutter/util/local_network_helper.dart';
import 'package:autonomy_flutter/util/log.dart';
import 'package:autonomy_flutter/view/user_agent_utils.dart' as my_device;
import 'package:collection/collection.dart';
Expand Down Expand Up @@ -78,7 +79,7 @@ class CanvasClientService {
..device = (DeviceInfo()
..deviceId = _deviceId
..deviceName = _deviceName);

await LocalNetworkHelper.requestLocalNetworkPermission();
final response = await stub.connect(
request,
options: _callOptions,
Expand Down
14 changes: 14 additions & 0 deletions lib/util/local_network_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:network_info_plus/network_info_plus.dart';
phuocbitmark marked this conversation as resolved.
Show resolved Hide resolved
phuocbitmark marked this conversation as resolved.
Show resolved Hide resolved

class LocalNetworkHelper {
static Future<bool> requestLocalNetworkPermission() async {
bool isGranted = false;
try {
final wifiIp = await NetworkInfo().getWifiIP();
phuocbitmark marked this conversation as resolved.
Show resolved Hide resolved
phuocbitmark marked this conversation as resolved.
Show resolved Hide resolved
isGranted = true;
} catch (e) {
isGranted = false;
}
return isGranted;
}
}
20 changes: 18 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
network_info_plus:
dependency: "direct main"
description:
name: network_info_plus
sha256: "5bd4b86e28fed5ed4e6ac7764133c031dfb7d3f46aa2a81b46f55038aa78ecc0"
url: "https://pub.dev"
source: hosted
version: "5.0.3"
network_info_plus_platform_interface:
dependency: transitive
description:
name: network_info_plus_platform_interface
sha256: "2e193d61d3072ac17824638793d3b89c6d581ce90c11604f4ca87311b42f2706"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
phuocbitmark marked this conversation as resolved.
Show resolved Hide resolved
nft_collection:
dependency: "direct main"
description:
Expand Down Expand Up @@ -3099,5 +3115,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.2.0 <4.0.0"
flutter: ">=3.16.0"
dart: ">=3.2.3 <4.0.0"
flutter: ">=3.16.6"
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ dependencies:
git:
url: https://github.com/autonomy-system/nft-collection
ref: 103d9009bd87a5d95123c53dd0a0ee4da6bc3904
network_info_plus: ^5.0.3
feralfile_app_tv_proto:
git:
url: https://github.com/autonomy-system/feralfile-app-tv-proto-communication
Expand Down
Loading