Description
We are experiencing a compatibility issue with the Aptabase Flutter SDK when running on the web platform. The error occurs due to Hive's BoxCollection not being compatible with the web environment, resulting in the following error:
TypeError: dart.nullCheck(...)[$open] is not a function
Steps to Reproduce
- Set up a Flutter project with the Aptabase Flutter SDK.
- Configure Aptabase with a valid app key.
- Run the application on the web platform using
flutter run -d chrome
. - Observe the error in the console.
Expected Behavior
The application should initialize Aptabase without errors on the web platform.
Actual Behavior
The application throws a TypeError related to Hive's BoxCollection when attempting to initialize Aptabase on the web platform.
Environment
- Aptabase Version: 0.4.1
- Flutter Version: 3.32.4
Flutter Doctor Output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.32.4, on macOS 15.2 24C101 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] Connected device (3 available)
[✓] Network resources
• No issues found!
Additional Context
The issue seems to be related to Hive's BoxCollection, which is not fully compatible with the web platform. Disabling Aptabase on the web resolves the error, but this limits analytics capabilities.
Proposed Solution
Consider providing a web-compatible storage solution or guidance on how to handle analytics on the web platform without Hive.
Error log
TypeError: dart.nullCheck(...)[$open] is not a function
package:hive/src/box_collection/box_collection_stub.dart.lib.js 3328:77 <fn>
dart:sdk_internal 44282:13 <fn>
dart:sdk_internal 44292:7 <fn>
dart:sdk_internal 44240:5 _asyncStartSync
package:hive/src/box_collection/box_collection_stub.dart.lib.js 3366:20 open
package:hive/src/box_collection/box_collection_stub.dart.lib.js 6608:55 <fn>
dart:sdk_internal 44282:13 <fn>
dart:sdk_internal 44292:7 <fn>
dart:sdk_internal 44240:5 _asyncStartSync
package:hive/src/box_collection/box_collection_stub.dart.lib.js 6672:20 [_openBox]
package:hive/src/box_collection/box_collection_stub.dart.lib.js 6694:54 <fn>
dart:sdk_internal 44282:13 <fn>
dart:sdk_internal 44292:7 <fn>
dart:sdk_internal 44240:5 _asyncStartSync
package:hive/src/box_collection/box_collection_stub.dart.lib.js 6706:20 openBox
package:aptabase_flutter/storage_manager_hive.dart.lib.js 68:50 <fn>
dart:sdk_internal 44282:13 <fn>
dart:sdk_internal 44292:7 <fn>
dart:sdk_internal 44259:42 <fn>
dart:sdk_internal 43193:59 runUnary
dart:sdk_internal 35859:26 handleValue
dart:sdk_internal 36558:47 handleValueCallback
dart:sdk_internal 36596:15 _propagateToListeners
dart:sdk_internal 36415:21 [_completeWithValue]
dart:sdk_internal 36461:33 callback
dart:sdk_internal 44642:13 _microtaskLoop
dart:sdk_internal 44649:13 _startMicrotaskLoop
dart:sdk_internal 3792:46 tear
dart:sdk_internal 36899:9 <fn>