hive_ce 2.4.2 copy "hive_ce: ^2.4.2" to clipboard
hive_ce: ^2.4.2 copied to clipboard

Hive Community Edition - A spiritual continuation of Hive v2

example/lib/main.dart

import 'dart:io';

import 'package:example/hive_registrar.g.dart';
import 'package:hive_ce/hive.dart';

part 'main.g.dart';

@HiveType(typeId: 1)
class Person {
  Person({required this.name, required this.age, required this.friends});

  @HiveField(0)
  String name;

  @HiveField(1)
  int age;

  @HiveField(2)
  List<String> friends;

  @override
  String toString() {
    return '$name: $age';
  }
}

void main() async {
  final path = Directory.current.path;
  Hive
    ..init(path)
    ..registerAdapters();

  final box = await Hive.openBox('testBox');

  final person = Person(
    name: 'Dave',
    age: 22,
    friends: ['Linda', 'Marc', 'Anne'],
  );

  await box.put('dave', person);

  print(box.get('dave')); // Dave: 22
}
69
likes
0
pub points
92%
popularity

Publisher

verified publisheriodesignteam.com

Hive Community Edition - A spiritual continuation of Hive v2

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

crypto, meta, web

More

Packages that depend on hive_ce