https://github.com/helightdev/chainmail
https://github.com/helightdev/chainmail
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/helightdev/chainmail
- Owner: helightdev
- License: apache-2.0
- Created: 2022-06-04T00:26:19.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-01T15:25:50.000Z (almost 4 years ago)
- Last Synced: 2025-02-22T09:33:02.530Z (about 1 year ago)
- Language: Dart
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Features
Chainmail offers a mixin based extension model to improve code quality.
You might already know mixins and their advantages from the infamous
TickerProvider mixins.
The package ships with following features already implemented:
* Extensible mixin based chain model
* Full integrations with the default state class
* `Blocs`: Bind to list of blocs and listen to updated
* `Loading`: Await a future and show a placeholder
* `Errors`: Catch custom or loading errors and show them
* `Responsive`: Implement orientation specific build methods
* `Disposables`: Register StreamSubscriptions and dispose callbacks
* `LateRender`: Wait for one frame before building to access the RenderBox
## Usage
To use chainmail extensions, just change your state implementations
type to ChainmailState and implement the `mainBuild` method instead of `build`.
```dart
class ExampleWidget extends StatefulWidget {
const ExampleWidget({Key? key}) : super(key: key);
@override
State createState() => ExampleState();
}
class ExampleState extends ChainmailState {
@override
Widget mainBuild() => const Text("Hello World");
}
```
You can use the BuildContext as usual with the `context` variable, which in
this case is declared at class level and is accessible from everywhere inside
the class and always up-to-date. You can also use one of the numerous
quality of life getters for common scenarios, like getting MediaQueries or
accessing the nearest Theme and TextTheme.
To use an extension (from now on referred to as chainlinks), just use the `with`
keyword followed by the mixin class. You then possibly have to implement
required methods.
```dart
class ExampleState extends ChainmailState with Loading {
@override
Widget mainBuild() => const Text("Test!");
@override
Future initialize() async {
await Future.delayed(const Duration(seconds: 1));
}
}
```
The chainlinks will be applied in natural order, contrary to the "common"
reverse order, because of readability.