I am trying to save values with Hive so that they are saved even after my app is closed. This is the code I am running:
@override
void initState() {
super.initState();
box = Hive.box('exerciseBox');
}
addInfo() {
box.put('Exercise 1', exercise1);
box.put('Exercise 1 Time', exercise1time);
return Text("");
}
getInfo() {
exercise1 = box.get('Exercise 1');
exercise1time = box.get('Exercise 1 Time');
return Text("");
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
SizedBox(
height: 20,
),
const Text(
'Schedule:',
style: TextStyle(fontSize: 30),
textAlign: TextAlign.left,
),
if (exercise1 != "") ...[
addInfo(),
getInfo(),
one(exercise1),
There is more code after this but this is where I add and get data. But after I close app and open it exercise values are not saved. Pls help! Why isn't data saved?!