Closed shaadart closed 3 years ago
You could use HiveObject to quickly fix this issue. Firstly extend your model from HiveObject. Then call .save()
after modifying model.
class StreakModel extends HiveObject {
String streakName;
int streakCount;
String streakEmoji;
String streakRemainder;
int streakDays;
}
@TheMisir I always look forward for your answers, they are really beautiful. Can I Get the minimal Code Example. I did not Got the Thing that you are needing to convey, I know it is beautiful. 🐝 #Hive
@madd-project check this example out:
class StreakModel extends HiveObject {
String streakName;
int streakCount;
String streakEmoji;
String streakRemainder;
int streakDays;
}
void main() {
final streak = Hive.box<StreakModel>('streaks').get(1); // assuming streaks box is already opened using (Hive.openBox)
streak.streakDays++;
streak.save();
}
@TheMisir Thanks Buddy.. But can You tell me,
What is the 1
in the Line
final streak = Hive.box
('streaks').get(1); // assuming streaks box is already opened using (Hive.openBox)
What is the
1
in the Line
Ignore that line. The answer to your question is streak.save()
part.
Thanks alot It works, I was Drumming my head with a hammer, although I will recover from the scratches, (no worries) , Because of you, I really tackled this, Love You @TheMisir ❤️
Question I have come Across an Issue, I have a Model, Which Looks Like this.
I have then written Some Values in them and used,
streakBox.add(streak)
As we all do, But the Question is, I want to Update up theint streakCount
on the Button Press, by+1
I had Tried,
streak.streakCount++;
and every other tactic, but the Changes are not Stored Locally Effectively. Can I get the relevant answer to this? I am Hungry to fetch this.Version