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

Hive Community Edition - A spiritual continuation of Hive v2

example/lib/main.dart

import 'dart:io';

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)
    ..registerAdapter(PersonAdapter());

  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
}
4
likes
160
pub points
63%
popularity

Publisher

verified publisheriodesignteam.com

Hive Community Edition - A spiritual continuation of Hive v2

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

Apache-2.0 (LICENSE)

Dependencies

crypto, meta, web

More

Packages that depend on hive_ce