Skip to main content

Flutter Troubleshooting

This document provides solutions to common issues encountered while using the GlamAR SDK in Flutter projects.

Common Issues and Solutions

1. Installation Problems

Issue: Errors during package installation.

Solution:

  • Ensure that your Flutter environment is correctly set up by following the Flutter setup guide.
  • Verify that all required packages (flutter_inappwebview, permission_handler) are added to your pubspec.yaml file and run flutter pub get to install them.

2. Camera Permission Denied

Issue: The SDK does not function because camera permission is denied.

Solution:

  • For Android, ensure that the following permissions are added to AndroidManifest.xml:
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-feature android:name="android.hardware.camera" android:required="true"/>
  • For iOS, add the following to Info.plist:
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera for showing virtual try-ons</string>
  • Ensure that the onPermissionRequest method is correctly implemented to handle permission requests.

3. SDK Initialization Fails

Issue: The SDK does not initialize properly.

Solution:

Ensure that the Access key is correctly set in the initialization payload:

final overrides = GlamAROverrides(
category: 'skinanalysis',
configuration: {
'skinAnalysis': {
'appId': 'YOUR_skin-app-id',
},
},
);

await GlamAr.init(
accessKey: 'YOUR_ACCESS_KEY', // Replace with your actual key
overrides: overrides
);
  • Replace 'YOUR_ACCESS_KEY' with the correct access key from your organization.

4. Image URL Not Loading

Issue: The API returns a delivery.pixelbin.io image URL, but the image does not render in the Flutter app.

Solution:

Pass an empty Referer request header when loading the image:

Image.network(
imageUrl,
headers: const {
'Referer': '',
},
)

If you use cached_network_image, pass the same header through httpHeaders:

CachedNetworkImage(
imageUrl: imageUrl,
httpHeaders: const {
'Referer': '',
},
)

referrerPolicy="no-referrer" is only supported by web browsers. In Flutter, use request headers on the image request instead.

5. Additional Tips

  • Always test your application on both Android and iOS devices to ensure compatibility.
  • Keep your Flutter SDK and all dependencies up to date to avoid compatibility issues.

For further assistance, refer to the official documentation or contact support.