-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from IO-Design-Team/feature/generate-adapters-…
…refactoring Refactoring from `generate-adapters` branch
- Loading branch information
Showing
36 changed files
with
647 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
target: auto | ||
threshold: 5% | ||
base: auto | ||
patch: | ||
default: | ||
target: auto | ||
threshold: 5% | ||
base: auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:hive_ce/hive.dart'; | ||
|
||
@HiveType(typeId: 0) | ||
class Person extends HiveObject { | ||
Person({required this.name, required this.age}); | ||
|
||
@HiveField(0) | ||
String name; | ||
|
||
@HiveField(1) | ||
int age; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:hive_ce/hive.dart'; | ||
|
||
@HiveType(typeId: 0) | ||
class Person extends HiveObject { | ||
Person({required this.name, required this.age, this.balance = 0}); | ||
|
||
@HiveField(0) | ||
String name; | ||
|
||
@HiveField(1) | ||
int age; | ||
|
||
@HiveField(2) | ||
double balance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:hive_ce/hive.dart'; | ||
import 'hive_cipher_impl.dart'; | ||
|
||
void example() async { | ||
// Create a box collection | ||
final collection = await BoxCollection.open( | ||
// Name of your database | ||
'MyFirstFluffyBox', | ||
// Names of your boxes | ||
{'cats', 'dogs'}, | ||
// Path where to store your boxes (Only used in Flutter / Dart IO) | ||
path: './', | ||
// Key to encrypt your boxes (Only used in Flutter / Dart IO) | ||
key: HiveCipherImpl(), | ||
); | ||
|
||
// Open your boxes. Optional: Give it a type. | ||
final catsBox = await collection.openBox<Map>('cats'); | ||
|
||
// Put something in | ||
await catsBox.put('fluffy', {'name': 'Fluffy', 'age': 4}); | ||
await catsBox.put('loki', {'name': 'Loki', 'age': 2}); | ||
|
||
// Get values of type (immutable) Map? | ||
final loki = await catsBox.get('loki'); | ||
print('Loki is ${loki?['age']} years old.'); | ||
|
||
// Returns a List of values | ||
final cats = await catsBox.getAll(['loki', 'fluffy']); | ||
print(cats); | ||
|
||
// Returns a List<String> of all keys | ||
final allCatKeys = await catsBox.getAllKeys(); | ||
print(allCatKeys); | ||
|
||
// Returns a Map<String, Map> with all keys and entries | ||
final catMap = await catsBox.getAllValues(); | ||
print(catMap); | ||
|
||
// delete one or more entries | ||
await catsBox.delete('loki'); | ||
await catsBox.deleteAll(['loki', 'fluffy']); | ||
|
||
// ...or clear the whole box at once | ||
await catsBox.clear(); | ||
|
||
// Speed up write actions with transactions | ||
await collection.transaction( | ||
() async { | ||
await catsBox.put('fluffy', {'name': 'Fluffy', 'age': 4}); | ||
await catsBox.put('loki', {'name': 'Loki', 'age': 2}); | ||
// ... | ||
}, | ||
boxNames: ['cats'], // By default all boxes become blocked. | ||
readOnly: false, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:hive_ce/hive.dart'; | ||
|
||
class HiveCipherImpl extends HiveCipher { | ||
@override | ||
int calculateKeyCrc() => throw UnimplementedError(); | ||
|
||
@override | ||
int decrypt( | ||
Uint8List inp, | ||
int inpOff, | ||
int inpLength, | ||
Uint8List out, | ||
int outOff, | ||
) => | ||
throw UnimplementedError(); | ||
|
||
@override | ||
int encrypt( | ||
Uint8List inp, | ||
int inpOff, | ||
int inpLength, | ||
Uint8List out, | ||
int outOff, | ||
) => | ||
throw UnimplementedError(); | ||
|
||
@override | ||
int maxEncryptedSize(Uint8List inp) => throw UnimplementedError(); | ||
} |
Oops, something went wrong.