Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while using isolates #696

Open
Aruljebaraj opened this issue Nov 28, 2024 · 1 comment
Open

Issue while using isolates #696

Aruljebaraj opened this issue Nov 28, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Aruljebaraj
Copy link

Aruljebaraj commented Nov 28, 2024

I’ve implemented a singleton pattern for the ObjectBox class in my Flutter project, and it works correctly when accessed normally. However, when I started implementing isolates, I'm encountering a LateInitializationError.

`import 'package:inspectassist_bloc/objectbox.g.dart';

class ObjectBox {
late final Store store;
late final Box testBox;

ObjectBox._create(this.store) {
testBox = Box(store);
}

static late final ObjectBox _instance;

static Future init() async {
_instance = ObjectBox._create(await openStore());
}

static ObjectBox get instance => _instance;
}`

LateInitializationError: Field '_instance@85511379' has not been initialized.
#0 ObjectBox._instance (package:inspectassist_bloc/Database/ObjectBox.dart)
#1 ObjectBox.instance (package:inspectassist_bloc/Database/ObjectBox.dart:59:36)

is there any solution to fix this

@Aruljebaraj Aruljebaraj added the bug Something isn't working label Nov 28, 2024
@Aruljebaraj
Copy link
Author

  • tried to initialise it again
  • BackgroundIsolateBinaryMessenger.ensureInitialized(rootIsolateToken); // rootToken -- null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant