Box not found. Did you forget to call Hive.openBox()?
is the result of a call to Hive.openBox()
. It is shown in the console. However the widget works fine and the contents of the box is shown correctly! I mean I know that the box is NOT open, that's why I open it...
Error message:
======== Exception caught by widgets library =======================================================
The following HiveError was thrown building FutureBuilder<Box<CreditCardOverview>>(dirty, state: _FutureBuilderState<Box<CreditCardOverview>>#d0a4f):
Box not found. Did you forget to call Hive.openBox()?
My flutter code:
// ...
Expanded(
child: FutureBuilder(
future: Hive.openBox<CreditCardOverview>('ccOverview'),
builder: (BuildContext context, AsyncSnapshot snapshot) {
// ... builder function checking snapshot etc.
}
// ....
UPDATE This is the complete code of the state :
class _FinancialsListSmallState extends State<FinancialsListSmall> {
@override
Widget build(BuildContext context) {
final sizeX = MediaQuery.of(context).size.width;
final sizeY = MediaQuery.of(context).size.height - MediaQuery.of(context).viewInsets.bottom;
return SafeArea(
child: Container(
width: sizeX,
height: sizeY,
child: Column(
children: [
PageTitleSmall(titleText: 'My Credit Cards', leadingIcon: Icon(Icons.credit_card)),
Expanded(
child: FutureBuilder(
future: Hive.openBox<CreditCardOverview>('ccOverview'),
builder: (BuildContext context, AsyncSnapshot snapshot) {
List<Widget> children;
if (snapshot.hasData) {
children = <Widget>[
const Icon(
Icons.check_circle_outline,
color: Colors.green,
size: 60,
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text('Result: ${snapshot.data}'),
)
];
} else if (snapshot.hasError) {
children = <Widget>[
const Icon(
Icons.error_outline,
color: Colors.red,
size: 60,
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text('Error: ${snapshot.error}'),
)
];
} else {
children = const <Widget>[
SizedBox(
child: CircularProgressIndicator(),
width: 60,
height: 60,
),
Padding(
padding: EdgeInsets.only(top: 16),
child: Text('Awaiting result...'),
)
];
}
return ListView(
children: showCreditCardOverview(),
);
},
),
),
],
),
),
);
}
Any ideal what is going on here?