Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
simc committed Aug 22, 2023
1 parent d3e1546 commit 388e9e6
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 4 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Hive release

on:
push:
tags:
- "*"

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Setup Dart
uses: dart-lang/setup-dart@v1
- name: Wait for tests to succeed
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
running-workflow-name: "Release"
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: pub.dev credentials
run: |
mkdir -p $HOME/.config/dart
echo '${{ secrets.PUB_JSON }}' >> $HOME/.config/dart/pub-credentials.json
- name: Publish hive
run: |
dart pub get
dart pub publish --force
141 changes: 141 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
## 🌼 Welcome, Beekeeper! 🐝

Let's embark on a buzzworthy journey into the world of Flutter and Dart using Hive! Ready to see Hive in action? This example will walk you through setting up a Flutter project and implementing Hive to store data on a list of favorite flowers for bees.

## 🌺 Buzzy Beginnings

Create a new Flutter app:

```bash
flutter create bee_favorites
cd bee_favorites
```

Now we can add some sweet dependencies to our `pubspec.yaml`:

```yaml
dependencies:
flutter:
sdk: flutter
hive: ^4.0.0
isar_flutter_libs: ^4.0.0-dev.13
path_provider: ^2.0.0
```
## 🌻 Setting up Hive
Before we get into the code, let's set up Hive:
```dart
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();

final directory = await getApplicationDocumentsDirectory();
Hive.defaultDirectory = directory.path;

runApp(BeeApp());
}
```

## 🌸 Bee Favorites App

Let's build a simple Flutter app where bees can vote for their favorite flowers!

```dart
class BeeApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Bee Favorites',
theme: ThemeData(primarySwatch: Colors.yellow),
home: FavoriteFlowers(),
);
}
}
class FavoriteFlowers extends StatefulWidget {
@override
_FavoriteFlowersState createState() => _FavoriteFlowersState();
}
class _FavoriteFlowersState extends State<FavoriteFlowers> {
final Box<String> favoriteBox = Hive.box<String>('favorites');
final List<String> flowers = ['Rose', 'Tulip', 'Daisy', 'Lily', 'Sunflower'];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Bee Favorites 🐝')),
body: ListView.builder(
itemCount: flowers.length,
itemBuilder: (context, index) {
final flower = flowers[index];
return ListTile(
title: Text(flower),
trailing: IconButton(
icon: Icon(Icons.star),
onPressed: () {
favoriteBox.add(flower);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('$flower added to favorites! 🌼')),
);
},
),
);
},
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.view_list),
onPressed: () {
showDialog(
context: context,
builder: (context) => FavoritesDialog(favorites: favoriteBox.values.toList()),
);
},
),
);
}
}
class FavoritesDialog extends StatelessWidget {
final List<String> favorites;
FavoritesDialog({required this.favorites});
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text('Bee Favorites 🌼'),
content: Container(
width: 300,
height: 200,
child: ListView.builder(
itemCount: favorites.length,
itemBuilder: (context, index) {
return ListTile(title: Text(favorites[index]));
},
),
),
actions: [
TextButton(
child: Text('Close'),
onPressed: () => Navigator.of(context).pop(),
),
],
);
}
}
```

## 🐝 Bee-fore You Go...

Once you've completed this tutorial, run your app! Every time a bee (or user) selects a flower, it's added to the favorites list, and you can view the favorites with the FloatingActionButton!

> **Bee fact:** Bees communicate through a combination of chemical scents and movements. One known movement is the waggle dance, which indicates the location of a food source!
Check out the full documentation in Hive's readme and the other example apps.
1 change: 1 addition & 0 deletions lib/src/hive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Hive {
engine: encryptionKey != null ? IsarEngine.sqlite : IsarEngine.isar,
maxSizeMiB: maxSizeMiB,
encryptionKey: encryptionKey,
inspector: false,
);
final newBox = _BoxImpl<E>(isar);
_openBoxes[name] = newBox;
Expand Down
17 changes: 13 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
name: hive
description: Lightweight and blazing fast key-value database written in pure Dart. Strongly encrypted using AES-256.
description: Lightweight and buzzing-fast key-value database made for Flutter and Dart.
version: 4.0.0-dev.0
homepage: https://github.com/hivedb/hive/tree/master/hive
documentation: https://docs.hivedb.dev/
repository: https://github.com/isar/hive
homepage: https://github.com/isar/hive
issue_tracker: https://github.com/isar/hive/issues
funding:
- https://github.com/sponsors/simc/
topics:
- database
- hive
- nosql
- encryption
- storage

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">=3.1.0 <4.0.0"

dependencies:
isar: ^4.0.0-dev.13
Expand Down

0 comments on commit 388e9e6

Please sign in to comment.