Skip to content

Commit

Permalink
new: v1.1.0
Browse files Browse the repository at this point in the history
- upd: minimum supported SDK version to Flutter 3.13/Dart 3.1.0
- fix: incorrect assert message about initialization, close #12
- 🧨upd: if you used `CollectionConverter` and its inheritors, you are now only allowed to use them by using `extends` and adding `final` modifier to your class (or `base`|`sealed`)
- 🧨upd: `Cardoteka.setPrefix` now static. Add `allowList` parameter. The `prefix` now named parameter.
- 🧨add: use `CardotekaUtilsForTest.setMockInitialCards` method instead of `CardotekaUtilsForTest.setMockInitialValues`, which is now responsible for the original `SharedPreferences.setMockInitialValues` method. Close #16
- doc: `Obfuscate`, `Materials`, `Apps`, `Saving null values` sections were added to readme

You can see all closed issues in [Milestone v1.1.0](https://github.com/PackRuble/cardoteka/milestone/1?closed=1)
  • Loading branch information
PackRuble committed Oct 2, 2024
1 parent 40d138f commit a162f53
Show file tree
Hide file tree
Showing 24 changed files with 223 additions and 173 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test_and_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
Expand All @@ -27,6 +27,6 @@ jobs:

steps:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ pubspec.lock
.flutter-plugins
.flutter-plugins-dependencies
build/

coverage/
24 changes: 17 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
## [1.0.1] - 22-12-2023
## [1.1.0] - 02-10-2024

- upd: minimum supported SDK version to Flutter 3.13/Dart 3.1.0
- fix: incorrect assert message about initialization, close #12
- 🧨upd: if you used `CollectionConverter` and its inheritors, you are now only allowed to use them by using `extends` and adding `final` modifier to your class (or `base`|`sealed`)
- 🧨upd: `Cardoteka.setPrefix` now static. Add `allowList` parameter. The `prefix` now named parameter.
- 🧨add: use `CardotekaUtilsForTest.setMockInitialCards` method instead of `CardotekaUtilsForTest.setMockInitialValues`, which is now responsible for the original `SharedPreferences.setMockInitialValues` method. Close #16
- doc: `Obfuscate`, `Materials`, `Apps`, `Saving null values` sections were added to readme

### Other
You can see all closed issues in [Milestone v1.1.0](https://github.com/PackRuble/cardoteka/milestone/1?closed=1)

## [1.0.1] - 22-12-2023

- fix: remove invalid example from `example`
- upd: description

## [1.0.0] - 22-12-2023

- first public release 🎊
- fully documented code
- with examples of use in the `example/lib` folder
- code is covered by tests (with a coverage percentage >80%)
- prepared readme.md with architecture overview
first public release 🎊

- fully documented code
- with examples of use in the `example/lib` folder
- code is covered by tests (with a coverage percentage >80%)
- prepared readme.md with architecture overview

## [0.0.1] - 04-11-2022

Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2022-2023 Ruble. All rights reserved.
Copyright © 2022-2024 Ruble. All rights reserved.
Author: Ruble

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,20 @@ Why should I prefer to use [`cardoteka`](https://pub.dev/packages/cardoteka) ins
* [Advantages](#advantages)
* [Table of contents](#table-of-contents)
* [How to use?](#how-to-use)
* [Materials](#materials)
* [Apps](#apps)
* [Use with...](#use-with)
* [ChangeNotifier](#changenotifier)
* [ValueNotifier](#valuenotifier)
* [Cubit (bloc)](#cubit-bloc)
* [Provider (riverpod)](#provider-riverpod)
* [Saving null values](#saving-null-values)
* [Structure](#structure)
* [Cardoteka](#cardoteka-1)
* [Card](#card)
* [Converter](#converter)
* [Watcher](#watcher)
* [Obfuscate](#obfuscate)
* [Coverage](#coverage)
* [Author](#author)
<!-- TOC -->
Expand Down Expand Up @@ -86,6 +90,8 @@ class SettingsCardoteka extends Cardoteka with WatcherImpl {

```dart
main() async {
WidgetsFlutterBinding.ensureInitialized();
await Cardoteka.init();
final cardoteka = SettingsCardoteka(
config: CardotekaConfig(
Expand Down Expand Up @@ -138,6 +144,21 @@ main() async {

**Don't worry!** If you do something wrong, you will receive a detailed correction message in the console.

## Materials

List of resources to learn more about the capabilities of this library:
- [Я сделал Cardoteka и вот как её использовать [кто любит черпать] / Хабр](https://habr.com/ru/articles/783712/)
- [Stop using dynamic key-value storage! Use Cardoteka for typed access to Shared Preferences | by Ruble | Medium](https://medium.com/@pack.ruble/stop-using-dynamic-key-value-storage-use-cardoteka-for-typed-access-to-shared-preferences-567c9f799d7d)
- [Cardoteka — техническая начинка и аналитика решений типобезопасной SP [кто любит вдаваться] / Хабр](https://habr.com/ru/articles/801089/)
- [Приложение викторины: внедрение Cardoteka и основные паттерны проектирования с Riverpod / Хабр](https://habr.com/ru/articles/799437/)

## Apps

Applications that use this library:
- [Weather Today](https://github.com/PackRuble/weather_today) - weather app
- [Quiz Prize](https://github.com/PackRuble/quiz_prize_app) - quiz game deployed on [web](https://packruble.github.io/quiz_prize_app)
- [PackRuble/reactive_domain_playground](https://github.com/PackRuble/reactive_domain_playground) - sandbox for practicing skills in a reactive Domain layer

## Use with...

All the most up-to-date examples can be found in the [example/lib](https://github.com/PackRuble/cardoteka/tree/dev/example/lib) folder of this project. Here are just some simple practices to use with different tools.
Expand Down Expand Up @@ -405,6 +426,23 @@ Future<void> main() async {
}
```

## Saving null values

If your card can contain a null value, then use the `getOrNull` and `setOrNull` methods. It works like this:
- `getOrNull` - if pair is absent in storage, we will get `null`
- `setOrNull` - if we save `null`, the pair will be deleted from storage

Below is a table showing the compatibility of methods with cards:

| method | Card<Object\> | Card<Object?> |
|:-----------:|:-------------:|:-------------:|
| `get` |||
| `set` |||
| `getOrNull` |||
| `setOrNull` |||

By and large, most often you will use `get`/`set`, and when you need to simulate working with null, or when there is no pair, you want to get `null` (and not the default value) - we use `getOrNull`/ `setOrNull`.

## Structure

The structure of the library is very simple! Below are the main classes you will have to work with.
Expand Down Expand Up @@ -473,6 +511,14 @@ Calling the `attach` method returns the actual value from storage OR the default

It is important to emphasize that you can implement your own solution based on `Watcher`.

## Obfuscate

At the time of writing, the [documentation](https://docs.flutter.dev/deployment/obfuscate#caveat) states that obfuscation does not apply to `Enum`:

> Enum names are not obfuscated currently.
However, this behavior may change in the future. So for now you can safely use `String get key => name;` as keys for your cards.

## Coverage

The most important "core" is covered by the tests part and all the places that needed covering in my opinion. There are badges at the very beginning of the current file where you can see the percentage of coverage, among other things. Or, click on the image below. It's relevant for releases.
Expand All @@ -497,7 +543,7 @@ You can contact me or check out my activities on the following platforms:
>
> With respect to everyone involved, Ruble.
[telegram_badge]: https://img.shields.io/badge/Telegram%20channel-❤️-_?style=plastic&logo=telegram&color=33cccc
[telegram_badge]: https://img.shields.io/badge/Telegram_channel-❤️-_?style=plastic&logo=telegram&color=33cccc
[telegram_link]: https://t.me/+AkGV73kZi_Q1YTMy

[pub_badge]: https://img.shields.io/pub/v/cardoteka.svg?style=plastic
Expand Down
3 changes: 3 additions & 0 deletions example/lib/cardoteka_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class SettingsCardoteka extends Cardoteka with WatcherImpl {
}

void main() async {
// if binding occurs before runApp is called
WidgetsFlutterBinding.ensureInitialized();

await Cardoteka.init();
final cardoteka = SettingsCardoteka(
config: CardotekaConfig(
Expand Down
Loading

0 comments on commit a162f53

Please sign in to comment.