Fix validated upstream issues: LateInit handlers (#8), updateNode (#6), dep constraints (#26, #29) - #6
Conversation
…, widen deps (hlefe#26, hlefe#29) - ARSessionManager.onPlaneOrPointTap/onPlaneDetected: late -> nullable, fixes 'LateInitializationError: Field onPlaneDetected has not been initialized' (hlefe#8) - ARObjectManager.updateNode(): add the documented transform-sync method that was referenced by the maintainer but never existed; reuses the native 'transformationChanged' handler (#6) - pubspec: widen permission_handler to >=11.3.1 <13.0.0 (hlefe#26); bump Dart SDK upper bound to <4.0.0 (hlefe#29, hygiene) - tests: regression tests for hlefe#8 and #6
There was a problem hiding this comment.
Code Review
This pull request introduces the updateNode method to ARObjectManager to synchronize node transformations with the native AR engine, resolves potential LateInitializationErrors in ARSessionManager by making event handlers nullable, updates dependency constraints in pubspec.yaml, and adds corresponding regression tests. The review feedback suggests minor improvements: using const for the MatrixValueNotifierConverter instantiation to avoid unnecessary runtime allocations, and replacing the null-assertion operator (!) with the safer, more idiomatic null-aware call operator (?.call(...)) when invoking the nullable event handlers.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| await _channel.invokeMethod<void>('transformationChanged', { | ||
| 'name': node.name, | ||
| 'transformation': | ||
| MatrixValueNotifierConverter().toJson(node.transformNotifier), |
There was a problem hiding this comment.
Since MatrixValueNotifierConverter has a const constructor, you can instantiate it as a compile-time constant using const to avoid unnecessary runtime object allocations.
| MatrixValueNotifierConverter().toJson(node.transformNotifier), | |
| const MatrixValueNotifierConverter().toJson(node.transformNotifier), |
There was a problem hiding this comment.
Done in 01450b36df05a7651d3a3de7856f299ef60089d0 — applied as suggested. Thanks!
| return ARHitTestResult.fromJson(e); | ||
| }).toList(); | ||
| onPlaneOrPointTap(hitTestResults); | ||
| onPlaneOrPointTap!(hitTestResults); |
There was a problem hiding this comment.
Using the null-assertion operator ! on a mutable instance field is discouraged in Dart because the field's value could theoretically change or be set to null. It is more idiomatic and safer to use the null-aware call operator ?.call(...) instead.
| onPlaneOrPointTap!(hitTestResults); | |
| onPlaneOrPointTap?.call(hitTestResults); |
There was a problem hiding this comment.
Done in 01450b36df05a7651d3a3de7856f299ef60089d0 — applied as suggested. Thanks!
| if (onPlaneDetected != null) { | ||
| final planeCountResult = call.arguments as int; | ||
| onPlaneDetected(planeCountResult); | ||
| onPlaneDetected!(planeCountResult); |
There was a problem hiding this comment.
There was a problem hiding this comment.
Done in 01450b36df05a7651d3a3de7856f299ef60089d0 — applied as suggested. Thanks!
… never send Android's handleTransformNode only calls result.* when handlePans||handleRotation is enabled; both default to false, so an awaited transformationChanged would hang. Mirror removeNode (void, no await). Document the Android gesture-flag requirement.
Review loop — ✅ clean after 2 iterationsIteration 1 — found a BLOCKER: Fix applied: made Iteration 2 — LGTM. BLOCKER resolved and confirmed against the native code. No regressions. Accepted tradeoff (not fixed, by design): a fire-and-forget invoke can log an uncaught async error if gestures are enabled and the node is missing ( Verification: |
- const MatrixValueNotifierConverter() to avoid a runtime allocation - onPlaneOrPointTap/onPlaneDetected: use ?.call(...) instead of ! on mutable fields Per gemini-code-assist review on PR #6.
Addresses open issues from upstream hlefe/ar_flutter_plugin_2 that were validated as real bugs reproducible in this codebase. Native-only and device-specific issues are handled elsewhere or deferred (see bottom).
Fixes
🐛
LateInitializationErroron session callbacks — upstream hlefe#8ARSessionManager.onPlaneOrPointTapandonPlaneDetectedwere declaredlate(non-nullable), but_platformCallHandlerguards them withif (x != null). Reading an unsetlatefield throwsLateInitializationError: Field 'onPlaneDetected' has not been initialized.— exactly the error reported. Made both nullable (matchingonError), so the guards work and the callbacks are optional. Also removes twounnecessary_null_comparisonanalyzer warnings.✨ Add
ARObjectManager.updateNode()— upstream #6The maintainer told users to call
objectManager.updateNode(node)to sync transforms, but the method never existed. Added it — it invokes thetransformationChangedplatform method that the Android and iOS sides already handle, so no native change is needed.📦 Widen
permission_handlerto>=11.3.1 <13.0.0— upstream hlefe#26Allows
permission_handler12.x (resolves to 12.0.3). All APIs used (Permission.camera,PermissionStatus.*,openAppSettings) are stable across 11→12. Widened rather than pinned so 11.x users aren't forced to upgrade.🧹 Bump Dart SDK upper bound
<3.0.0→<4.0.0— related to upstream hlefe#29 (hygiene)Honest note: hlefe#29's reported symptom (incompatible with Flutter 3.35.6) did not reproduce here — pub's Dart-3 compatibility mode resolves fine against
<3.0.0on Dart 3.12. This bump removes the fragile reliance on that compat shim; it is hygiene, not a verified fix for hlefe#29's exact symptom.Verification
flutter analyze lib test→ 0 errors; the two targetedunnecessary_null_comparisonwarnings are gone.flutter test→ 3 passing, including new regression tests for Model is seen on Android but IOS is not. hlefe/ar_flutter_plugin_2#8 and Fix validated upstream issues: LateInit handlers (#8), updateNode (#6), dep constraints (#26, #29) #6.latedeclaration and pass after the fix.permission_handlerwidening and SDK bump both re-resolve cleanly viaflutter pub get.pubspec.lockintentionally not modified (not authoritative for a plugin; regenerated onpub get).Not included (validated + routed elsewhere / deferred)
[#"node-name quirk), Fail to load GLB from File System - Might have a FIX hlefe/ar_flutter_plugin_2#21/[Bug] 3D model not showing even after applying file:// fix + Depth & Occlusion not working hlefe/ar_flutter_plugin_2#22 (native GLBfile:/// occlusion) — native-side, not verifiable without a device; deferred.