Skip to content

Commit

Permalink
chore(hydrated_bloc): v10.0.0 (#4324)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored Jan 12, 2025
1 parent a94d4fc commit 3e001fd
Show file tree
Hide file tree
Showing 124 changed files with 73 additions and 4,550 deletions.
33 changes: 33 additions & 0 deletions packages/hydrated_bloc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# 10.0.0

- **BREAKING** feat!: support for `wasm` ([#4313](https://github.com/felangel/bloc/pull/4313))

- introduces `HydratedStorageDirectory` and modifies `HydratedStorage.build` signature to use `HydratedStorageDirectory` instead of `Directory` from `dart:io`

```dart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:path_provider/path_provider.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
HydratedBloc.storage = await HydratedStorage.build(
storageDirectory: kIsWeb
? HydratedStorageDirectory.web
: HydratedStorageDirectory((await getTemporaryDirectory()).path),
);
runApp(const App());
}
```

- feat: allow overriding storage per bloc/cubit instance ([#4314](https://github.com/felangel/bloc/pull/4314))
- feat: migrate to `package:hive_ce` (Hive Community Edition) ([#4262](https://github.com/felangel/bloc/pull/4262))
- fix: `HydratedStorage.build` should not cache instance ([#4317](https://github.com/felangel/bloc/pull/4317))
- chore: upgrade to `package:bloc v9.0.0`
- chore: bump miniumum Dart SDK version to 2.14
- chore: update sponsors
- chore: add `funding` to `pubspec.yaml` ([#4200](https://github.com/felangel/bloc/pull/4200))

# 9.1.5

- chore: update copyright year
Expand Down
22 changes: 20 additions & 2 deletions packages/hydrated_bloc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Now the `CounterCubit` and `CounterBloc` will automatically persist/restore thei
```dart
class CounterCubit extends Cubit<int> with HydratedMixin {
CounterCubit() : super(0) {
hydrate();
hydrate(); // You must always call `hydrate` when using `HydratedMixin`
}
void increment() => emit(state + 1);
Expand All @@ -127,6 +127,24 @@ class CounterCubit extends Cubit<int> with HydratedMixin {
}
```

## Storage Overrides

You can override the global storage instance for specific `HydratedBloc` or `HydratedCubit` instances by passing a custom storage instance via constructor.

```dart
class CounterCubit extends HydratedCubit<int> {
CounterCubit() : super(0, storage: EncryptedStorage());
void increment() => emit(state + 1);
@override
int fromJson(Map<String, dynamic> json) => json['value'] as int;
@override
Map<String, int> toJson(int state) => { 'value': state };
}
```

## Custom Storage Directory

Any `storageDirectory` can be used when creating an instance of `HydratedStorage`:
Expand Down Expand Up @@ -211,7 +229,7 @@ testWidgets('...', (tester) async {

## Dart Versions

- Dart 2: >= 2.12
- Dart 2: >= 2.14

## Maintainers

Expand Down
10 changes: 5 additions & 5 deletions packages/hydrated_bloc/example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668"
revision: "17025dd88227cd9532c33fa78f5250d548d87e9a"
channel: "stable"

project_type: app
Expand All @@ -13,11 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
- platform: web
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a

# User provided section

Expand Down
17 changes: 2 additions & 15 deletions packages/hydrated_bloc/example/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# example
# Hydrated Bloc Example

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
A sample project that showcases how to use package:hydrated_bloc.
13 changes: 0 additions & 13 deletions packages/hydrated_bloc/example/android/.gitignore

This file was deleted.

72 changes: 0 additions & 72 deletions packages/hydrated_bloc/example/android/app/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions packages/hydrated_bloc/example/android/build.gradle

This file was deleted.

3 changes: 0 additions & 3 deletions packages/hydrated_bloc/example/android/gradle.properties

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions packages/hydrated_bloc/example/android/settings.gradle

This file was deleted.

Loading

0 comments on commit 3e001fd

Please sign in to comment.