var box = await Hive.openBox('myBox');
box.put('name', 'Alice');
print(box.get('name')); // Alice
var box = await Hive.openBox<int>('numbers');
box.add(42);
import 'package:hive/hive.dart';
part 'word.g.dart';
@HiveType(typeId: 0)
class Word extends HiveObject {
@HiveField(0)
String mainKey;
@HiveField(1)
String subKey;
Word({required this.mainKey, required this.subKey});
}
var box = await Hive.openBox<Word>('words');
Box<Word>型part 'word.g.dart';
TypeAdapterを自動生成するために必要@HiveType(typeId: 0)
typeId:Hive内でクラスを識別する一位の番号HiveObject
save()/delete()/refresh()など@HiveField(0)
(n):
String mainKey;
String subKey;
Word({required this.mainKey, required this.subKey});