Skip to content

LateInitializationError: Field '_appKey@45410441' has not been initialized. #24

@JosipDomazetDev

Description

@JosipDomazetDev

Hi,

I recently upgraded my Aptabase version in Flutter and now my tests are failing with the following exception:

The following LateError was thrown running a test:
LateInitializationError: Field '_appKey@45410441' has not been initialized.

Previously, I didn't need to initialize the app key for tests. The track method seemed designed to handle this, as it was null-safe and included a check for an empty app key:

Future<void> trackEvent(
    String eventName, [
    Map<String, dynamic>? props,
  ]) async {
    if (_appKey.isEmpty || _apiUrl == null) {
      _logInfo("Tracking is disabled!");

      return;
    }
...

However, in a previous commit, the _appKey was changed from a static String to static late final, which is causing the LateInitializationError.

Could you please provide guidance on how to properly handle this in integration tests?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions