CariusLars / ar_flutter_plugin

Flutter Plugin for AR (Augmented Reality) - Supports ARKit on iOS and ARCore on Android devices
MIT License
322 stars 233 forks source link

Example for class LocalAndWebObjectsWidget() does not cater for null safety #51

Open KomengTech opened 2 years ago

KomengTech commented 2 years ago

The example class LocalAndWebObjectsWidget() does not cater for null safety.

this.localObjectNode = null; // error 'Null' can't be assigned to a variable of type 'ARNode'

bool didAddFileSystemNode = await this.arObjectManager.addNode(newNode); // error bool not bool?

Above are some examples.

My pubspec.yaml environment is:

environment: sdk: ">=2.12.0 <3.0.0"

How do I fix this? Thank you.

CariusLars commented 2 years ago

I guess you could just change the type of localObjectNode to ARNode? instead of ARNode to allow the null value, then before passing it to the addNode function just add a null check and only invoke the function if it's not null