-
Notifications
You must be signed in to change notification settings - Fork 393
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
[Question] #2
Comments
No it should be an instance of |
Odd. I'm messing around with using Hive on Windows, and I'm using Provider to send a box down the widget tree. I create it in the root widget like so:
When I access it in a different widget, like so: |
If I'm correct, the problem here is that I'm working on helpers for Flutter but until then you could use something like that: class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: FutureBuilder<Box>(
future: Hive.box('SettingsBox'),
builder: (BuildContext context, AsyncSnapshot<Box> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return SomePage();
} else {
return Center(
child: Text('Please wait'),
);
}
},
),
);
}
}
class SomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
var box = Hive['SettingsBox'];
// Do whatever you like with the box
return Center(
child: Text('Your App content'),
);
}
} Btw: you don't have to pass boxes. If you already opened it, you can get the box instance using |
Okay, thank you very much! |
I created a basic example if you are interested... |
Thanks! |
When creating a new box, like so:
var box = await Hive.box('SettingsBox');
isbox
null until a value has been put into the box?The text was updated successfully, but these errors were encountered: