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

Replace-print-statements-with-developer.log #196

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
34 changes: 20 additions & 14 deletions lib/managers/ar_anchor_manager.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer' as developer;

import 'package:ar_flutter_plugin/models/ar_anchor.dart';
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -27,9 +29,8 @@ class ARAnchorManager {
ARAnchorManager(int id, {this.debug = false}) {
_channel = MethodChannel('aranchors_$id');
_channel.setMethodCallHandler(_platformCallHandler);
if (debug) {
print("ARAnchorManager initialized");
}

developer.log("$runtimeType initialized");
}

/// Activates collaborative AR mode (using Google Cloud Anchors)
Expand All @@ -38,19 +39,21 @@ class ARAnchorManager {
}

Future<dynamic> _platformCallHandler(MethodCall call) async {
if (debug) {
print('_platformCallHandler call ${call.method} ${call.arguments}');
}
developer.log('_platformCallHandler call ${call.method} ${call.arguments}');

try {
switch (call.method) {
case 'onError':
print(call.arguments);
developer.log(call.arguments);
break;
case 'onCloudAnchorUploaded':
final name = call.arguments["name"];
final cloudanchorid = call.arguments["cloudanchorid"];
print(
"UPLOADED ANCHOR WITH ID: " + cloudanchorid + ", NAME: " + name);

developer.log(
"UPLOADED ANCHOR WITH ID: " + cloudanchorid + ", NAME: " + name,
);

final currentAnchor =
pendingAnchors.where((element) => element.name == name).first;
// Update anchor with cloud anchor ID
Expand All @@ -72,13 +75,15 @@ class ARAnchorManager {
return serializedAnchor["name"];
}
default:
if (debug) {
print('Unimplemented method ${call.method} ');
}
developer.log('Unknown method ${call.method}');
}
} catch (e) {
print('Error caught: ' + e.toString());
developer.log(
'Exception in platform call handler: $e',
name: 'ar_anchor_manager',
);
}

return Future.value();
}

Expand Down Expand Up @@ -110,7 +115,8 @@ class ARAnchorManager {

/// Try to download anchor with the given ID from the Google Cloud Anchor API and add it to the scene
Future<bool?> downloadAnchor(String cloudanchorid) async {
print("TRYING TO DOWNLOAD ANCHOR WITH ID " + cloudanchorid);
developer.log("TRYING TO DOWNLOAD ANCHOR WITH ID " + cloudanchorid);

_channel
.invokeMethod<bool>('downloadAnchor', {"cloudanchorid": cloudanchorid});
}
Expand Down
7 changes: 6 additions & 1 deletion lib/managers/ar_location_manager.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'dart:async';
import 'dart:developer' as developer;

import 'package:geolocator/geolocator.dart';

/// Can be used to get the current location of the device, update it and handle location permissions
Expand Down Expand Up @@ -80,7 +82,10 @@ class ARLocationManager {
locationStream =
Geolocator.getPositionStream(desiredAccuracy: LocationAccuracy.high)
.listen((Position position) {
//print(position.latitude.toString() + ', ' + position.longitude.toString());
developer.log(
'$runtimeType::getPositionStream: ${position.latitude}, ${position.longitude}',
);

currentLocation = position;
});

Expand Down
19 changes: 8 additions & 11 deletions lib/managers/ar_object_manager.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:developer' as developer;
import 'dart:typed_data';

import 'package:ar_flutter_plugin/models/ar_anchor.dart';
Expand Down Expand Up @@ -35,19 +36,17 @@ class ARObjectManager {
ARObjectManager(int id, {this.debug = false}) {
_channel = MethodChannel('arobjects_$id');
_channel.setMethodCallHandler(_platformCallHandler);
if (debug) {
print("ARObjectManager initialized");
}

developer.log("$runtimeType initialized");
}

Future<void> _platformCallHandler(MethodCall call) {
if (debug) {
print('_platformCallHandler call ${call.method} ${call.arguments}');
}
developer.log('_platformCallHandler call ${call.method} ${call.arguments}');

try {
switch (call.method) {
case 'onError':
print(call.arguments);
developer.log(call.arguments);
break;
case 'onNodeTap':
if (onNodeTap != null) {
Expand Down Expand Up @@ -104,12 +103,10 @@ class ARObjectManager {
}
break;
default:
if (debug) {
print('Unimplemented method ${call.method} ');
}
developer.log('Unimplemented method ${call.method}');
}
} catch (e) {
print('Error caught: ' + e.toString());
developer.log('Error in $runtimeType: $e');
}
return Future.value();
}
Expand Down
23 changes: 11 additions & 12 deletions lib/managers/ar_session_manager.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer' as developer;

import 'dart:typed_data';
import 'package:ar_flutter_plugin/models/ar_hittest_result.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -28,21 +30,19 @@ class ARSessionManager {
{this.debug = false}) {
_channel = MethodChannel('arsession_$id');
_channel.setMethodCallHandler(_platformCallHandler);
if (debug) {
print("ARSessionManager initialized");
}

developer.log("ARSessionManager initialized");
}

Future<void> _platformCallHandler(MethodCall call) {
if (debug) {
print('_platformCallHandler call ${call.method} ${call.arguments}');
}
developer.log('_platformCallHandler call ${call.method} ${call.arguments}');

try {
switch (call.method) {
case 'onError':
if (onError != null) {
onError(call.arguments[0]);
print(call.arguments);
developer.log(call.arguments);
}
break;
case 'onPlaneOrPointTap':
Expand All @@ -62,13 +62,12 @@ class ARSessionManager {
_channel.invokeMethod<void>("dispose");
break;
default:
if (debug) {
print('Unimplemented method ${call.method} ');
}
developer.log('Unimplemented method ${call.method} ');
}
} catch (e) {
print('Error caught: ' + e.toString());
developer.log('Error in ARSessionManager._platformCallHandler: $e');
}

return Future.value();
}

Expand Down Expand Up @@ -114,7 +113,7 @@ class ARSessionManager {
try {
await _channel.invokeMethod<void>("dispose");
} catch (e) {
print(e);
developer.log("Error disposing ARSessionManager: $e");
}
}

Expand Down
8 changes: 6 additions & 2 deletions lib/widgets/ar_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer' as developer;

import 'package:ar_flutter_plugin/managers/ar_anchor_manager.dart';
import 'package:ar_flutter_plugin/managers/ar_location_manager.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -60,7 +62,8 @@ class AndroidARView implements PlatformARView {

@override
void onPlatformViewCreated(int id) {
print("Android platform view created!");
developer.log("Android platform view created!");

createManagers(id, _context, _arViewCreatedCallback, _planeDetectionConfig);
}

Expand Down Expand Up @@ -95,7 +98,8 @@ class IosARView implements PlatformARView {

@override
void onPlatformViewCreated(int id) {
print("iOS platform view created!");
developer.log("iOS platform view created!");

createManagers(id, _context, _arViewCreatedCallback, _planeDetectionConfig);
}

Expand Down