Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7785f3f117
|
||
|
|
e030375fec
|
||
|
|
375bb8f04a | ||
|
|
1cadba5cd5
|
||
|
|
75340f1b5a
|
||
|
|
78456c01a6
|
||
|
|
45458e7784
|
@@ -3,6 +3,42 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## 2023-11-18
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Packages with breaking changes:
|
||||||
|
|
||||||
|
- There are no breaking changes in this release.
|
||||||
|
|
||||||
|
Packages with other changes:
|
||||||
|
|
||||||
|
- [`wyatt_bloc_helper` - `v2.0.2`](#wyatt_bloc_helper---v202)
|
||||||
|
- [`wyatt_bloc_layout` - `v0.1.2+5`](#wyatt_bloc_layout---v0125)
|
||||||
|
- [`wyatt_cloud_messaging_bloc_base` - `v0.1.1+3`](#wyatt_cloud_messaging_bloc_base---v0113)
|
||||||
|
- [`wyatt_i18n` - `v2.0.2`](#wyatt_i18n---v202)
|
||||||
|
- [`wyatt_ui_kit` - `v3.2.4`](#wyatt_ui_kit---v324)
|
||||||
|
- [`wyatt_cloud_messaging_bloc_firebase` - `v0.1.0+3`](#wyatt_cloud_messaging_bloc_firebase---v0103)
|
||||||
|
|
||||||
|
Packages with dependency updates only:
|
||||||
|
|
||||||
|
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
|
||||||
|
|
||||||
|
- `wyatt_bloc_layout` - `v0.1.2+5`
|
||||||
|
- `wyatt_cloud_messaging_bloc_base` - `v0.1.1+3`
|
||||||
|
- `wyatt_i18n` - `v2.0.2`
|
||||||
|
- `wyatt_ui_kit` - `v3.2.4`
|
||||||
|
- `wyatt_cloud_messaging_bloc_firebase` - `v0.1.0+3`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### `wyatt_bloc_helper` - `v2.0.2`
|
||||||
|
|
||||||
|
- **FIX**: compilation issue with flutter 3.16.0 and generics name.
|
||||||
|
|
||||||
|
|
||||||
## 2023-11-14
|
## 2023-11-14
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|||||||
@@ -36,23 +36,23 @@
|
|||||||
|
|
||||||
<!-- code_chunk_output -->
|
<!-- code_chunk_output -->
|
||||||
|
|
||||||
* [About](#about)
|
- [About](#about)
|
||||||
* [Contribution](#contribution)
|
- [Usage](#usage)
|
||||||
+ [Prerequisite](#prerequisite)
|
- [Contribution](#contribution)
|
||||||
+ [Create a new package](#create-a-new-package)
|
- [Prerequisite](#prerequisite)
|
||||||
|
- [Create a new package](#create-a-new-package)
|
||||||
- [Naming](#naming)
|
- [Naming](#naming)
|
||||||
+ [Create issues](#create-issues)
|
- [Create issues](#create-issues)
|
||||||
+ [Branches](#branches)
|
- [Branches](#branches)
|
||||||
+ [Commits](#commits)
|
- [Commits](#commits)
|
||||||
- [Before pushing](#before-pushing)
|
- [Before pushing](#before-pushing)
|
||||||
+ [Merge your work](#merge-your-work)
|
- [Merge your work](#merge-your-work)
|
||||||
+ [Update version.](#update-version)
|
- [Update version.](#update-version)
|
||||||
+ [Publish your package](#publish-your-package)
|
- [Publish your package](#publish-your-package)
|
||||||
+ [Badging](#badging)
|
- [Badging](#badging)
|
||||||
* [Usage](#usage)
|
- [Simple work flow diagramm](#simple-work-flow-diagramm)
|
||||||
* [Simple work flow diagramm](#simple-work-flow-diagramm)
|
- [Status](#status)
|
||||||
* [Status](#status)
|
- [License](#license)
|
||||||
* [License](#license)
|
|
||||||
|
|
||||||
<!-- /code_chunk_output -->
|
<!-- /code_chunk_output -->
|
||||||
|
|
||||||
@@ -68,6 +68,21 @@ Those packages are developed by [Wyatt Studio](https://wyatt-studio.fr) and are
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
You can add any package of the `packages/` sub directory in your project.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
dependencies:
|
||||||
|
wyatt_analysis:
|
||||||
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
|
||||||
|
version: ^2.4.1
|
||||||
|
```
|
||||||
|
|
||||||
|
> You can also use the `git` protocol. But it's not recommended since it's not handle version constraints.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
Clone this repo.
|
Clone this repo.
|
||||||
@@ -109,12 +124,17 @@ Create a new package in `packages/` folder.
|
|||||||
To create a new package in the packages/ folder, run the following command in the terminal:
|
To create a new package in the packages/ folder, run the following command in the terminal:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
mason make wyatt_package_template --package_name <name> --description A new Wyatt package --flutter false
|
mason upgrade
|
||||||
|
mason make wyatt_package_template \
|
||||||
|
--package_name <name> \
|
||||||
|
--description A new Wyatt package \
|
||||||
|
--flutter false
|
||||||
|
-o packages/<name>
|
||||||
```
|
```
|
||||||
|
|
||||||
> Browse our [bricks](https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-bricks) for more information.
|
> Browse our [bricks](https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-bricks) for more information.
|
||||||
|
|
||||||
The <name> variable in the above command is important and must be clear and understandable.
|
The `<name>` variable in the above command is important and must be clear and understandable. (see [Naming](#naming))
|
||||||
|
|
||||||
After creating the package, bootstrap the project with the `melos bs` command.
|
After creating the package, bootstrap the project with the `melos bs` command.
|
||||||
|
|
||||||
@@ -129,7 +149,7 @@ It have to be clear and intelligible.
|
|||||||
For example, if the name is `CRUD BLOC` the following naming conventions should be used:
|
For example, if the name is `CRUD BLOC` the following naming conventions should be used:
|
||||||
|
|
||||||
1. package name: `wyatt_crud_bloc`
|
1. package name: `wyatt_crud_bloc`
|
||||||
2. example name: `example`
|
2. example name: `wyatt_crud_bloc_example`
|
||||||
|
|
||||||
### Create issues
|
### Create issues
|
||||||
|
|
||||||
@@ -141,7 +161,9 @@ For example, if you want to work on the `i18n` package, you should create an iss
|
|||||||
|
|
||||||
The `master` branch is protected and cannot be pushed to directly. Please create a separate branch for each feature or task, with a name that corresponds to the related issue. The branch name should follow this format:
|
The `master` branch is protected and cannot be pushed to directly. Please create a separate branch for each feature or task, with a name that corresponds to the related issue. The branch name should follow this format:
|
||||||
|
|
||||||
`scope/type/short-name`
|
```text
|
||||||
|
scope/type/short-name
|
||||||
|
```
|
||||||
|
|
||||||
For example, if you are working on the `i18n` package and you want to add a new feature, you should create a branch named `i18n/feat/add-new-feature` .
|
For example, if you are working on the `i18n` package and you want to add a new feature, you should create a branch named `i18n/feat/add-new-feature` .
|
||||||
|
|
||||||
@@ -172,9 +194,9 @@ Some examples :
|
|||||||
* `docs: update readme.` = update **this** readme file.
|
* `docs: update readme.` = update **this** readme file.
|
||||||
* `fix(crud)!: fix bug in awesome() function. (closes #32)` = fix a bug, `!` is important and indicate `BREAKING CHANGES` linked with the 32nd issue.
|
* `fix(crud)!: fix bug in awesome() function. (closes #32)` = fix a bug, `!` is important and indicate `BREAKING CHANGES` linked with the 32nd issue.
|
||||||
|
|
||||||
When you have completed your development work and are ready to resolve the related issue, you can close it via your commit message by including (closes #issue_number). For example:
|
When you have completed your development work and are ready to resolve the related issue, you can close it via your commit message by including `(closes #issue_number)` . For example:
|
||||||
|
|
||||||
```shell
|
```text
|
||||||
feat(auth): add AWS support. (closes #31)
|
feat(auth): add AWS support. (closes #31)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -262,22 +284,7 @@ or
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> Some packages requires Flutter, so please specify it.
|
> **Warning** Some packages requires Flutter, so please specify it.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
You can add any package of the `packages/` sub directory in your project.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
dependencies:
|
|
||||||
wyatt_analysis:
|
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
|
|
||||||
version: ^2.4.1
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can also use the `git` protocol. But it's not recommended since it's not handle version constraints.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"bricks":{"wyatt_component_template":{"git":{"url":"ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-bricks.git","path":"bricks/wyatt_component_template","ref":"7cea909470ce75b91840f479649b93f953ded596"}}}}
|
{"bricks":{"wyatt_component_template":{"git":{"url":"ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-bricks.git","path":"bricks/wyatt_component_template","ref":"0d2605717add29556b12ad1145e4457d71f18c18"}},"wyatt_package_template":{"git":{"url":"ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-bricks.git","path":"bricks/wyatt_package_template","ref":"0d2605717add29556b12ad1145e4457d71f18c18"}}}}
|
||||||
@@ -16,7 +16,7 @@ command:
|
|||||||
linkToCommits: false # Gitea not yet supported
|
linkToCommits: false # Gitea not yet supported
|
||||||
workspaceChangelog: true
|
workspaceChangelog: true
|
||||||
includeCommitId: false # Generate error in Melos 3...
|
includeCommitId: false # Generate error in Melos 3...
|
||||||
branch: master
|
# branch: master # Since we are using rebasing, we don't need to specify the branch
|
||||||
message: |
|
message: |
|
||||||
chore(release): publish packages
|
chore(release): publish packages
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ dependencies:
|
|||||||
|
|
||||||
wyatt_bloc_helper:
|
wyatt_bloc_helper:
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
|
||||||
version: ^2.0.1
|
version: ^2.0.2
|
||||||
wyatt_http_client:
|
wyatt_http_client:
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
|
||||||
version: ^2.0.1
|
version: ^2.0.1
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
## 2.0.2
|
||||||
|
|
||||||
|
- **FIX**: compilation issue with flutter 3.16.0 and generics name.
|
||||||
|
|
||||||
## 2.0.1
|
## 2.0.1
|
||||||
|
|
||||||
- **REFACTOR**: docs + nullable multiprovider attributes.
|
- **REFACTOR**: docs + nullable multiprovider attributes.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
* Copyright (C) 2022 WYATT GROUP
|
* Copyright (C) 2023 WYATT GROUP
|
||||||
* Please see the AUTHORS file for details.
|
* Please see the AUTHORS file for details.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ subprojects {
|
|||||||
project.evaluationDependsOn(':app')
|
project.evaluationDependsOn(':app')
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
tasks.register("clean", Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
version: 1.0.0+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.17.0 <3.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|
||||||
# Dependencies specify other packages that your package needs in order to work.
|
# Dependencies specify other packages that your package needs in order to work.
|
||||||
# To automatically upgrade your package dependencies to the latest versions
|
# To automatically upgrade your package dependencies to the latest versions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -24,10 +24,10 @@ import 'package:wyatt_bloc_helper/src/mixins/repository_base_provider_mixin.dart
|
|||||||
|
|
||||||
/// {@template bloc_provider}
|
/// {@template bloc_provider}
|
||||||
/// Need to implement a [create] function that is responsible for
|
/// Need to implement a [create] function that is responsible for
|
||||||
/// creating the [Bloc] and a [builder] which will return a child
|
/// creating the bloc [B] and a [builder] which will return a child
|
||||||
/// that have access to the instance via `context.read<Bloc>()`.
|
/// that have access to the instance via `context.read<Bloc>()`.
|
||||||
/// It is used as a dependency injection (DI) widget so that a single instance
|
/// It is used as a dependency injection (DI) widget so that a single instance
|
||||||
/// of a [Bloc] can be provided to multiple widgets within a subtree.
|
/// of a bloc [B] can be provided to multiple widgets within a subtree.
|
||||||
///
|
///
|
||||||
/// It automatically handles closing the instance when used with [create].
|
/// It automatically handles closing the instance when used with [create].
|
||||||
/// By default, [create] is called only when the instance is accessed.
|
/// By default, [create] is called only when the instance is accessed.
|
||||||
@@ -36,12 +36,12 @@ import 'package:wyatt_bloc_helper/src/mixins/repository_base_provider_mixin.dart
|
|||||||
/// By default, it provide already provided instance found in the tree.
|
/// By default, it provide already provided instance found in the tree.
|
||||||
/// To override this behavior, set [smart] to `false`.
|
/// To override this behavior, set [smart] to `false`.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class BlocProviderScreen<Bloc extends blocbase.Bloc<Event, State>,
|
abstract class BlocProviderScreen<B extends blocbase.Bloc<E, S>, E,
|
||||||
Event, State extends Object> extends BlocBaseProviderScreen<Bloc, State>
|
S extends Object> extends BlocBaseProviderScreen<B, S>
|
||||||
with
|
with
|
||||||
BlocBaseProviderMixin<Bloc>,
|
BlocBaseProviderMixin<B>,
|
||||||
RepositoryProviderMixin,
|
RepositoryProviderMixin,
|
||||||
BlocProviderMixin<Bloc, Event> {
|
BlocProviderMixin<B, E> {
|
||||||
/// {@macro bloc_provider}
|
/// {@macro bloc_provider}
|
||||||
const BlocProviderScreen({super.key, super.lazy = true, super.smart = true});
|
const BlocProviderScreen({super.key, super.lazy = true, super.smart = true});
|
||||||
}
|
}
|
||||||
@@ -53,11 +53,11 @@ abstract class BlocProviderScreen<Bloc extends blocbase.Bloc<Event, State>,
|
|||||||
/// An optional [shouldBuildWhen] and [shouldListenWhen] can be implemented
|
/// An optional [shouldBuildWhen] and [shouldListenWhen] can be implemented
|
||||||
/// for more granular control over when [onListen] and [onBuild] are called.
|
/// for more granular control over when [onListen] and [onBuild] are called.
|
||||||
/// The [shouldListenWhen] and [shouldBuildWhen] will be invoked on
|
/// The [shouldListenWhen] and [shouldBuildWhen] will be invoked on
|
||||||
/// each [Bloc] or `state` change.
|
/// each bloc [B] or `state` change.
|
||||||
/// They each take the previous `state` and current `state` and must return
|
/// They each take the previous `state` and current `state` and must return
|
||||||
/// a [bool] which determines whether or not the [onBuild] and/or [onListen]
|
/// a [bool] which determines whether or not the [onBuild] and/or [onListen]
|
||||||
/// function will be invoked.
|
/// function will be invoked.
|
||||||
/// The previous `state` will be initialized to the `state` of the [Bloc] when
|
/// The previous `state` will be initialized to the `state` of the bloc [B] when
|
||||||
/// the BlocConsumer is initialized.
|
/// the BlocConsumer is initialized.
|
||||||
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
|
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
|
||||||
/// aren't implemented, they will default to `true`.
|
/// aren't implemented, they will default to `true`.
|
||||||
@@ -65,28 +65,28 @@ abstract class BlocProviderScreen<Bloc extends blocbase.Bloc<Event, State>,
|
|||||||
/// An optional [parent] can also be implemented. This build a wrapper arround
|
/// An optional [parent] can also be implemented. This build a wrapper arround
|
||||||
/// the built BlocConsumer that is **not** rebuild on each state.
|
/// the built BlocConsumer that is **not** rebuild on each state.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class BlocConsumerScreen<Bloc extends blocbase.Bloc<Event, State>,
|
abstract class BlocConsumerScreen<B extends blocbase.Bloc<E, S>, E,
|
||||||
Event, State extends Object> extends BlocBaseConsumerScreen<Bloc, State>
|
S extends Object> extends BlocBaseConsumerScreen<B, S>
|
||||||
with
|
with
|
||||||
BlocBaseProviderMixin<Bloc>,
|
BlocBaseProviderMixin<B>,
|
||||||
RepositoryProviderMixin,
|
RepositoryProviderMixin,
|
||||||
BlocProviderMixin<Bloc, Event> {
|
BlocProviderMixin<B, E> {
|
||||||
/// {@macro bloc_consumer}
|
/// {@macro bloc_consumer}
|
||||||
const BlocConsumerScreen({super.key});
|
const BlocConsumerScreen({super.key});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// {@template bloc_screen}
|
/// {@template bloc_screen}
|
||||||
/// Provide AND access to a [Bloc].
|
/// Provide AND access to a bloc [B].
|
||||||
///
|
///
|
||||||
/// This extends [BlocConsumerScreen] with the methods
|
/// This extends [BlocConsumerScreen] with the methods
|
||||||
/// of [BlocBaseScreen].
|
/// of [BlocBaseScreen].
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class BlocScreen<Bloc extends blocbase.Bloc<Event, State>, Event,
|
abstract class BlocScreen<B extends blocbase.Bloc<E, S>, E, S extends Object>
|
||||||
State extends Object> extends BlocBaseScreen<Bloc, State>
|
extends BlocBaseScreen<B, S>
|
||||||
with
|
with
|
||||||
BlocBaseProviderMixin<Bloc>,
|
BlocBaseProviderMixin<B>,
|
||||||
RepositoryProviderMixin,
|
RepositoryProviderMixin,
|
||||||
BlocProviderMixin<Bloc, Event> {
|
BlocProviderMixin<B, E> {
|
||||||
/// {@macro bloc_screen}
|
/// {@macro bloc_screen}
|
||||||
const BlocScreen({super.key, super.lazy = true, super.smart = true});
|
const BlocScreen({super.key, super.lazy = true, super.smart = true});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -24,11 +24,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
/// An optional [shouldBuildWhen] and [shouldListenWhen] can be implemented
|
/// An optional [shouldBuildWhen] and [shouldListenWhen] can be implemented
|
||||||
/// for more granular control over when [onListen] and [onBuild] are called.
|
/// for more granular control over when [onListen] and [onBuild] are called.
|
||||||
/// The [shouldListenWhen] and [shouldBuildWhen] will be invoked on
|
/// The [shouldListenWhen] and [shouldBuildWhen] will be invoked on
|
||||||
/// each [Bloc] or `state` change.
|
/// each bloc [B] or `state` change.
|
||||||
/// They each take the previous `state` and current `state` and must return
|
/// They each take the previous `state` and current `state` and must return
|
||||||
/// a [bool] which determines whether or not the [onBuild] and/or [onListen]
|
/// a [bool] which determines whether or not the [onBuild] and/or [onListen]
|
||||||
/// function will be invoked.
|
/// function will be invoked.
|
||||||
/// The previous `state` will be initialized to the `state` of the [Bloc] when
|
/// The previous `state` will be initialized to the `state` of the bloc [B] when
|
||||||
/// the [BlocConsumer] is initialized.
|
/// the [BlocConsumer] is initialized.
|
||||||
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
|
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
|
||||||
/// aren't implemented, they will default to `true`.
|
/// aren't implemented, they will default to `true`.
|
||||||
@@ -36,39 +36,39 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
/// An optional [parent] can also be implemented. This build a wrapper arround
|
/// An optional [parent] can also be implemented. This build a wrapper arround
|
||||||
/// the built [BlocConsumer] that is **not** rebuild on each state.
|
/// the built [BlocConsumer] that is **not** rebuild on each state.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>,
|
abstract class BlocBaseConsumerScreen<B extends BlocBase<S>, S extends Object>
|
||||||
State extends Object> extends StatelessWidget {
|
extends StatelessWidget {
|
||||||
/// {@macro bloc_base_consumer}
|
/// {@macro bloc_base_consumer}
|
||||||
const BlocBaseConsumerScreen({super.key});
|
const BlocBaseConsumerScreen({super.key});
|
||||||
|
|
||||||
/// Takes the previous `state` and the current `state` and is responsible for
|
/// Takes the previous `state` and the current `state` and is responsible for
|
||||||
/// returning a [bool] which determines whether or not to trigger
|
/// returning a [bool] which determines whether or not to trigger
|
||||||
/// [onBuild] with the current `state`.
|
/// [onBuild] with the current `state`.
|
||||||
bool shouldBuildWhen(State previous, State current) => true;
|
bool shouldBuildWhen(S previous, S current) => true;
|
||||||
|
|
||||||
/// Takes the previous `state` and the current `state` and is responsible for
|
/// Takes the previous `state` and the current `state` and is responsible for
|
||||||
/// returning a [bool] which determines whether or not to trigger
|
/// returning a [bool] which determines whether or not to trigger
|
||||||
/// [onListen] with the current `state`.
|
/// [onListen] with the current `state`.
|
||||||
bool shouldListenWhen(State previous, State current) => true;
|
bool shouldListenWhen(S previous, S current) => true;
|
||||||
|
|
||||||
/// The [parent] function which will be invoked on build.
|
/// The [parent] function which will be invoked on build.
|
||||||
/// The [parent] takes a `BuildContext` that **doesn't have** access
|
/// The [parent] takes a `BuildContext` that **doesn't have** access
|
||||||
/// to the [Bloc] or [Cubit].
|
/// to the bloc [B] or [Cubit].
|
||||||
Widget parent(BuildContext context, Widget child) => child;
|
Widget parent(BuildContext context, Widget child) => child;
|
||||||
|
|
||||||
/// The [onBuild] function which will be invoked on each widget build.
|
/// The [onBuild] function which will be invoked on each widget build.
|
||||||
/// The [onBuild] takes the `BuildContext` and current `state` and
|
/// The [onBuild] takes the `BuildContext` and current `state` and
|
||||||
/// must return a widget.
|
/// must return a widget.
|
||||||
Widget onBuild(BuildContext context, State state);
|
Widget onBuild(BuildContext context, S state) => const SizedBox.shrink();
|
||||||
|
|
||||||
/// Takes the `BuildContext` along with the `state`
|
/// Takes the `BuildContext` along with the `state`
|
||||||
/// and is responsible for executing in response to `state` changes.
|
/// and is responsible for executing in response to `state` changes.
|
||||||
void onListen(BuildContext context, State state) {}
|
void onListen(BuildContext context, S state) {}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => parent(
|
Widget build(BuildContext context) => parent(
|
||||||
context,
|
context,
|
||||||
BlocConsumer<Bloc, State>(
|
BlocConsumer<B, S>(
|
||||||
listenWhen: shouldListenWhen,
|
listenWhen: shouldListenWhen,
|
||||||
listener: onListen,
|
listener: onListen,
|
||||||
buildWhen: shouldBuildWhen,
|
buildWhen: shouldBuildWhen,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -20,10 +20,10 @@ import 'package:wyatt_bloc_helper/src/utils/smart_provider.dart';
|
|||||||
|
|
||||||
/// {@template bloc_base_provider}
|
/// {@template bloc_base_provider}
|
||||||
/// Need to implement a [create] function that is responsible for
|
/// Need to implement a [create] function that is responsible for
|
||||||
/// creating the [Bloc] or [Cubit] and a [builder] which will return a child
|
/// creating the bloc or cubit [B] and a [builder] which will return a child
|
||||||
/// that have access to the instance via `context.read<Bloc>()`.
|
/// that have access to the instance via `context.read<Bloc>()`.
|
||||||
/// It is used as a dependency injection (DI) widget so that a single instance
|
/// It is used as a dependency injection (DI) widget so that a single instance
|
||||||
/// of a [Bloc] or [Cubit] can be provided to multiple widgets within a subtree.
|
/// of a bloc or cubit [B] can be provided to multiple widgets within a subtree.
|
||||||
///
|
///
|
||||||
/// It automatically handles closing the instance when used with [create].
|
/// It automatically handles closing the instance when used with [create].
|
||||||
/// By default, [create] is called only when the instance is accessed.
|
/// By default, [create] is called only when the instance is accessed.
|
||||||
@@ -32,8 +32,8 @@ import 'package:wyatt_bloc_helper/src/utils/smart_provider.dart';
|
|||||||
/// By default, it provide already provided instance found in the tree.
|
/// By default, it provide already provided instance found in the tree.
|
||||||
/// To override this behavior, set [smart] to `false`.
|
/// To override this behavior, set [smart] to `false`.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class BlocBaseProviderScreen<Bloc extends BlocBase<State>,
|
abstract class BlocBaseProviderScreen<B extends BlocBase<S>, S extends Object>
|
||||||
State extends Object> extends StatelessWidget {
|
extends StatelessWidget {
|
||||||
/// {@macro bloc_base_provider}
|
/// {@macro bloc_base_provider}
|
||||||
const BlocBaseProviderScreen({
|
const BlocBaseProviderScreen({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -41,32 +41,32 @@ abstract class BlocBaseProviderScreen<Bloc extends BlocBase<State>,
|
|||||||
this.smart = true,
|
this.smart = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Whether the [Bloc] or [Cubit] should be created lazily.
|
/// Whether the bloc or cubit [B] should be created lazily.
|
||||||
/// Defaults to `true` which means the [Bloc] or [Cubit] is created only when
|
/// Defaults to `true` which means the bloc or cubit [B] is created only when
|
||||||
/// accessed the first time, not when provided.
|
/// accessed the first time, not when provided.
|
||||||
final bool lazy;
|
final bool lazy;
|
||||||
|
|
||||||
/// Whether this uses [SmartProvider].
|
/// Whether this uses [SmartProvider].
|
||||||
/// Defaults to `true`. But if you want to provide new [Bloc] or [Cubit]
|
/// Defaults to `true`. But if you want to provide new bloc or cubit [B]
|
||||||
/// of a same type in a sub-tree you may have to disable this.
|
/// of a same type in a sub-tree you may have to disable this.
|
||||||
final bool smart;
|
final bool smart;
|
||||||
|
|
||||||
/// Creates the [Bloc] or [Cubit] to be used.
|
/// Creates the bloc or cubit [B] to be used.
|
||||||
Bloc create(BuildContext context);
|
B create(BuildContext context);
|
||||||
|
|
||||||
/// Initialize the [Bloc] or [Cubit].
|
/// Initialize the bloc or cubit [B].
|
||||||
///
|
///
|
||||||
/// This function is useful when using with [SmartProvider], because
|
/// This function is useful when using with [SmartProvider], because
|
||||||
/// if you want to pass an initial event to your bloc you can pass it in
|
/// if you want to pass an initial event to your bloc you can pass it in
|
||||||
/// `create` function but if you re-use the bloc below in the tree this event
|
/// `create` function but if you re-use the bloc below in the tree this event
|
||||||
/// will never be re-pass.
|
/// will never be re-pass.
|
||||||
Bloc init(BuildContext context, Bloc bloc) => bloc;
|
B init(BuildContext context, B bloc) => bloc;
|
||||||
|
|
||||||
/// Creates the child [Widget] to be used.
|
/// Creates the child [Widget] to be used.
|
||||||
Widget builder(BuildContext context);
|
Widget builder(BuildContext context);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => SmartProvider.bloc<Bloc, State>(
|
Widget build(BuildContext context) => SmartProvider.bloc<B, S>(
|
||||||
context,
|
context,
|
||||||
lazy: lazy,
|
lazy: lazy,
|
||||||
enable: smart,
|
enable: smart,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -20,14 +20,14 @@ import 'package:wyatt_bloc_helper/src/bloc_base/bloc_base_consumer_screen.dart';
|
|||||||
import 'package:wyatt_bloc_helper/src/utils/smart_provider.dart';
|
import 'package:wyatt_bloc_helper/src/utils/smart_provider.dart';
|
||||||
|
|
||||||
/// {@template bloc_base_screen}
|
/// {@template bloc_base_screen}
|
||||||
/// Provide AND access to a [Bloc] or [Cubit].
|
/// Provide AND access to a bloc or cubit [B].
|
||||||
///
|
///
|
||||||
/// This extends [BlocBaseConsumerScreen] with the methods
|
/// This extends [BlocBaseConsumerScreen] with the methods
|
||||||
// ignore: comment_references
|
// ignore: comment_references
|
||||||
/// of [BlocBaseProviderScreen].
|
/// of [BlocBaseProviderScreen].
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class BlocBaseScreen<Bloc extends BlocBase<State>,
|
abstract class BlocBaseScreen<B extends BlocBase<S>, S extends Object>
|
||||||
State extends Object> extends BlocBaseConsumerScreen<Bloc, State> {
|
extends BlocBaseConsumerScreen<B, S> {
|
||||||
/// {@macro bloc_base_screen}
|
/// {@macro bloc_base_screen}
|
||||||
const BlocBaseScreen({
|
const BlocBaseScreen({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -35,8 +35,8 @@ abstract class BlocBaseScreen<Bloc extends BlocBase<State>,
|
|||||||
this.smart = true,
|
this.smart = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Whether the [Bloc] or [Cubit] should be created lazily.
|
/// Whether the bloc or cubit [B] should be created lazily.
|
||||||
/// Defaults to `true` which means the [Bloc] is created only when
|
/// Defaults to `true` which means the bloc is created only when
|
||||||
/// accessed the first time, not when provided.
|
/// accessed the first time, not when provided.
|
||||||
final bool lazy;
|
final bool lazy;
|
||||||
|
|
||||||
@@ -45,19 +45,19 @@ abstract class BlocBaseScreen<Bloc extends BlocBase<State>,
|
|||||||
/// in a sub-tree you may have to disable this.
|
/// in a sub-tree you may have to disable this.
|
||||||
final bool smart;
|
final bool smart;
|
||||||
|
|
||||||
/// Creates the [Cubit] or [Bloc] to be used.
|
/// Creates the cubit or bloc to be used.
|
||||||
Bloc create(BuildContext context);
|
B create(BuildContext context);
|
||||||
|
|
||||||
/// Initialize the [Bloc] or [Cubit].
|
/// Initialize the bloc or cubit [B].
|
||||||
///
|
///
|
||||||
/// This function is useful when using with [SmartProvider], because
|
/// This function is useful when using with [SmartProvider], because
|
||||||
/// if you want to pass an initial event to your bloc you can pass it in
|
/// if you want to pass an initial event to your bloc you can pass it in
|
||||||
/// `create` function but if you re-use the bloc below in the tree this event
|
/// `create` function but if you re-use the bloc below in the tree this event
|
||||||
/// will never be re-pass.
|
/// will never be re-pass.
|
||||||
Bloc init(BuildContext context, Bloc bloc) => bloc;
|
B init(BuildContext context, B bloc) => bloc;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => SmartProvider.bloc<Bloc, State>(
|
Widget build(BuildContext context) => SmartProvider.bloc<B, S>(
|
||||||
context,
|
context,
|
||||||
lazy: lazy,
|
lazy: lazy,
|
||||||
enable: smart,
|
enable: smart,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -23,10 +23,10 @@ import 'package:wyatt_bloc_helper/src/mixins/repository_base_provider_mixin.dart
|
|||||||
|
|
||||||
/// {@template cubit_provider}
|
/// {@template cubit_provider}
|
||||||
/// Need to implement a [create] function that is responsible for
|
/// Need to implement a [create] function that is responsible for
|
||||||
/// creating the [Cubit] and a [builder] which will return a child
|
/// creating the cubit [C] and a [builder] which will return a child
|
||||||
/// that have access to the instance via `context.read<Cubit>()`.
|
/// that have access to the instance via `context.read<Cubit>()`.
|
||||||
/// It is used as a dependency injection (DI) widget so that a single instance
|
/// It is used as a dependency injection (DI) widget so that a single instance
|
||||||
/// of a [Cubit] can be provided to multiple widgets within a subtree.
|
/// of a cubit [C] can be provided to multiple widgets within a subtree.
|
||||||
///
|
///
|
||||||
/// It automatically handles closing the instance when used with [create].
|
/// It automatically handles closing the instance when used with [create].
|
||||||
/// By default, [create] is called only when the instance is accessed.
|
/// By default, [create] is called only when the instance is accessed.
|
||||||
@@ -35,9 +35,9 @@ import 'package:wyatt_bloc_helper/src/mixins/repository_base_provider_mixin.dart
|
|||||||
/// By default, it provide already provided instance in found in the tree.
|
/// By default, it provide already provided instance in found in the tree.
|
||||||
/// To override this behavior, set [smart] to `false`.
|
/// To override this behavior, set [smart] to `false`.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class CubitProviderScreen<Cubit extends blocbase.Cubit<State>,
|
abstract class CubitProviderScreen<C extends blocbase.Cubit<S>,
|
||||||
State extends Object> extends BlocBaseProviderScreen<Cubit, State>
|
S extends Object> extends BlocBaseProviderScreen<C, S>
|
||||||
with BlocBaseProviderMixin<Cubit>, RepositoryProviderMixin {
|
with BlocBaseProviderMixin<C>, RepositoryProviderMixin {
|
||||||
/// {@macro cubit_provider}
|
/// {@macro cubit_provider}
|
||||||
const CubitProviderScreen({super.key, super.lazy = true, super.smart = true});
|
const CubitProviderScreen({super.key, super.lazy = true, super.smart = true});
|
||||||
}
|
}
|
||||||
@@ -49,35 +49,35 @@ abstract class CubitProviderScreen<Cubit extends blocbase.Cubit<State>,
|
|||||||
/// An optional [shouldBuildWhen] and [shouldListenWhen] can be implemented
|
/// An optional [shouldBuildWhen] and [shouldListenWhen] can be implemented
|
||||||
/// for more granular control over when [onListen] and [onBuild] are called.
|
/// for more granular control over when [onListen] and [onBuild] are called.
|
||||||
/// The [shouldListenWhen] and [shouldBuildWhen] will be invoked on
|
/// The [shouldListenWhen] and [shouldBuildWhen] will be invoked on
|
||||||
/// each [Cubit] or `state` change.
|
/// each cubit [C] or `state` change.
|
||||||
/// They each take the previous `state` and current `state` and must return
|
/// They each take the previous `state` and current `state` and must return
|
||||||
/// a [bool] which determines whether or not the [onBuild] and/or [onListen]
|
/// a [bool] which determines whether or not the [onBuild] and/or [onListen]
|
||||||
/// function will be invoked.
|
/// function will be invoked.
|
||||||
/// The previous `state` will be initialized to the `state` of the [Cubit] when
|
/// The previous `state` will be initialized to the `state` of the cubit [C]
|
||||||
/// the BlocConsumer is initialized.
|
/// when the BlocConsumer is initialized.
|
||||||
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
|
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
|
||||||
/// aren't implemented, they will default to `true`.
|
/// aren't implemented, they will default to `true`.
|
||||||
///
|
///
|
||||||
/// An optional [parent] can also be implemented. This build a wrapper arround
|
/// An optional [parent] can also be implemented. This build a wrapper arround
|
||||||
/// the built BlocConsumer that is **not** rebuild on each state.
|
/// the built BlocConsumer that is **not** rebuild on each state.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class CubitConsumerScreen<Cubit extends blocbase.Cubit<State>,
|
abstract class CubitConsumerScreen<C extends blocbase.Cubit<S>,
|
||||||
State extends Object> extends BlocBaseConsumerScreen<Cubit, State>
|
S extends Object> extends BlocBaseConsumerScreen<C, S>
|
||||||
with BlocBaseProviderMixin<Cubit>, RepositoryProviderMixin {
|
with BlocBaseProviderMixin<C>, RepositoryProviderMixin {
|
||||||
/// {@macro cubit_consumer}
|
/// {@macro cubit_consumer}
|
||||||
const CubitConsumerScreen({super.key});
|
const CubitConsumerScreen({super.key});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// {@template cubit_screen}
|
/// {@template cubit_screen}
|
||||||
/// Provide AND access to a [Cubit].
|
/// Provide AND access to a cubit [C].
|
||||||
///
|
///
|
||||||
/// This extends [CubitConsumerScreen] with the methods
|
/// This extends [CubitConsumerScreen] with the methods
|
||||||
// ignore: comment_references
|
// ignore: comment_references
|
||||||
/// of [CubitProviderScreen].
|
/// of [CubitProviderScreen].
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class CubitScreen<Cubit extends blocbase.Cubit<State>,
|
abstract class CubitScreen<C extends blocbase.Cubit<S>, S extends Object>
|
||||||
State extends Object> extends BlocBaseScreen<Cubit, State>
|
extends BlocBaseScreen<C, S>
|
||||||
with BlocBaseProviderMixin<Cubit>, RepositoryProviderMixin {
|
with BlocBaseProviderMixin<C>, RepositoryProviderMixin {
|
||||||
/// {@macro cubit_screen}
|
/// {@macro cubit_screen}
|
||||||
const CubitScreen({super.key, super.lazy = true, super.smart = true});
|
const CubitScreen({super.key, super.lazy = true, super.smart = true});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -18,10 +18,10 @@ import 'package:flutter/widgets.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
/// A mixin that provides implementation of helper methods for
|
/// A mixin that provides implementation of helper methods for
|
||||||
/// [Bloc] and [Cubit] widgets.
|
/// bloc and cubit [B] widgets.
|
||||||
mixin BlocBaseProviderMixin<Bloc extends BlocBase<Object>> {
|
mixin BlocBaseProviderMixin<B extends BlocBase<Object>> {
|
||||||
/// Returns the [BlocBase] used by this [BlocBaseProviderMixin].
|
/// Returns the [BlocBase] used by this [BlocBaseProviderMixin].
|
||||||
Bloc bloc(BuildContext context) => context.read<Bloc>();
|
B bloc(BuildContext context) => context.read<B>();
|
||||||
|
|
||||||
/// Returns another [BlocBase] **not** used by this [BlocBaseProviderMixin].
|
/// Returns another [BlocBase] **not** used by this [BlocBaseProviderMixin].
|
||||||
/// Short hand for `context.read<AnotherBloc>();`
|
/// Short hand for `context.read<AnotherBloc>();`
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -17,12 +17,11 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart' as blocbase;
|
import 'package:flutter_bloc/flutter_bloc.dart' as blocbase;
|
||||||
|
|
||||||
/// [Bloc] specific mixin that provides implementation
|
/// Bloc [B] specific mixin that provides implementation
|
||||||
/// of helper methods for events.
|
/// of helper methods for events.
|
||||||
mixin BlocProviderMixin<Bloc extends blocbase.Bloc<Event, Object>, Event> {
|
mixin BlocProviderMixin<B extends blocbase.Bloc<E, Object>, E> {
|
||||||
/// Add an event to the [Bloc].
|
/// Add an event to the [B].
|
||||||
///
|
///
|
||||||
/// Short hand for `context.read<Bloc>().add(event)`.
|
/// Short hand for `context.read<Bloc>().add(event)`.
|
||||||
void add(BuildContext context, Event event) =>
|
void add(BuildContext context, E event) => context.read<B>().add(event);
|
||||||
context.read<Bloc>().add(event);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -20,7 +20,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
/// A mixin that provides implementation of helper methods for
|
/// A mixin that provides implementation of helper methods for
|
||||||
/// Repository widgets.
|
/// Repository widgets.
|
||||||
mixin RepositoryProviderMixin {
|
mixin RepositoryProviderMixin {
|
||||||
/// Returns the [Repository] used by this [Widget].
|
/// Returns the [R] used by this [Widget].
|
||||||
Repository repo<Repository>(BuildContext context) =>
|
R repo<R>(BuildContext context) => context.read<R>();
|
||||||
context.read<Repository>();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -19,10 +19,10 @@ import 'package:wyatt_bloc_helper/src/repository/repository_provider_screen.dart
|
|||||||
|
|
||||||
/// {@template repository_provider}
|
/// {@template repository_provider}
|
||||||
/// Need to implement a [create] function that is responsible for
|
/// Need to implement a [create] function that is responsible for
|
||||||
/// creating the [Repository] and a [builder] which will return a child
|
/// creating the [R] and a [builder] which will return a child
|
||||||
/// that have access to the instance via `context.read<Repository>()`.
|
/// that have access to the instance via `context.read<Repository>()`.
|
||||||
/// It is used as a dependency injection (DI) widget so that a single instance
|
/// It is used as a dependency injection (DI) widget so that a single instance
|
||||||
/// of a [Repository] can be provided to multiple widgets within a subtree.
|
/// of a [R] can be provided to multiple widgets within a subtree.
|
||||||
///
|
///
|
||||||
/// It automatically handles closing the instance when used with [create].
|
/// It automatically handles closing the instance when used with [create].
|
||||||
/// By default, [create] is called only when the instance is accessed.
|
/// By default, [create] is called only when the instance is accessed.
|
||||||
@@ -31,9 +31,9 @@ import 'package:wyatt_bloc_helper/src/repository/repository_provider_screen.dart
|
|||||||
/// By default, it provide already provided instance found in the tree.
|
/// By default, it provide already provided instance found in the tree.
|
||||||
/// To override this behavior, set [smart] to `false`.
|
/// To override this behavior, set [smart] to `false`.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class RepositoryProviderScreen<Repository>
|
abstract class RepositoryProviderScreen<R>
|
||||||
extends RepositoryBaseProviderScreen<Repository>
|
extends RepositoryBaseProviderScreen<R> with RepositoryProviderMixin {
|
||||||
with RepositoryProviderMixin {
|
|
||||||
/// {@macro repository_provider}
|
/// {@macro repository_provider}
|
||||||
|
@Deprecated('Useless provider screen. Use get_it instead.')
|
||||||
const RepositoryProviderScreen({super.key});
|
const RepositoryProviderScreen({super.key});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -19,10 +19,10 @@ import 'package:wyatt_bloc_helper/src/utils/smart_provider.dart';
|
|||||||
|
|
||||||
/// {@template repository_base_provider}
|
/// {@template repository_base_provider}
|
||||||
/// Need to implement a [create] function that is responsible for
|
/// Need to implement a [create] function that is responsible for
|
||||||
/// creating the [Repository] and a [builder] which will return a child
|
/// creating the [R] and a [builder] which will return a child
|
||||||
/// that have access to the instance via `context.read<Repository>()`.
|
/// that have access to the instance via `context.read<Repository>()`.
|
||||||
/// It is used as a dependency injection (DI) widget so that a single instance
|
/// It is used as a dependency injection (DI) widget so that a single instance
|
||||||
/// of a [Repository] can be provided to multiple widgets within a subtree.
|
/// of a [R] can be provided to multiple widgets within a subtree.
|
||||||
///
|
///
|
||||||
/// It automatically handles closing the instance when used with [create].
|
/// It automatically handles closing the instance when used with [create].
|
||||||
/// By default, [create] is called only when the instance is accessed.
|
/// By default, [create] is called only when the instance is accessed.
|
||||||
@@ -31,8 +31,7 @@ import 'package:wyatt_bloc_helper/src/utils/smart_provider.dart';
|
|||||||
/// By default, it provide already provided instance found in the tree.
|
/// By default, it provide already provided instance found in the tree.
|
||||||
/// To override this behavior, set [smart] to `false`.
|
/// To override this behavior, set [smart] to `false`.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
abstract class RepositoryBaseProviderScreen<Repository>
|
abstract class RepositoryBaseProviderScreen<R> extends StatelessWidget {
|
||||||
extends StatelessWidget {
|
|
||||||
/// {@macro repository_base_provider}
|
/// {@macro repository_base_provider}
|
||||||
const RepositoryBaseProviderScreen({
|
const RepositoryBaseProviderScreen({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -40,32 +39,32 @@ abstract class RepositoryBaseProviderScreen<Repository>
|
|||||||
this.smart = true,
|
this.smart = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Whether the [Repository] should be created lazily.
|
/// Whether the [R] should be created lazily.
|
||||||
/// Defaults to `true` which means the [Repository] is created only when
|
/// Defaults to `true` which means the [R] is created only when
|
||||||
/// accessed the first time, not when provided.
|
/// accessed the first time, not when provided.
|
||||||
final bool lazy;
|
final bool lazy;
|
||||||
|
|
||||||
/// Whether this uses [SmartProvider].
|
/// Whether this uses [SmartProvider].
|
||||||
/// Defaults to `true`. But if you want to provide new [Repository] of a
|
/// Defaults to `true`. But if you want to provide new [R] of a
|
||||||
/// same type in a sub-tree you may have to disable this.
|
/// same type in a sub-tree you may have to disable this.
|
||||||
final bool smart;
|
final bool smart;
|
||||||
|
|
||||||
/// Creates the [Repository] to be used.
|
/// Creates the [R] to be used.
|
||||||
Repository create(BuildContext context);
|
R create(BuildContext context);
|
||||||
|
|
||||||
/// Initialize the [Repository].
|
/// Initialize the [R].
|
||||||
///
|
///
|
||||||
/// This function is useful when using with [SmartProvider], because
|
/// This function is useful when using with [SmartProvider], because
|
||||||
/// if you want to pass an initial call on your repository you can
|
/// if you want to pass an initial call on your repository you can
|
||||||
/// call it in `create` function but if you re-provide the repo below in the
|
/// call it in `create` function but if you re-provide the repo below in the
|
||||||
/// tree this action will never be call again.
|
/// tree this action will never be call again.
|
||||||
Repository init(BuildContext context, Repository repository) => repository;
|
R init(BuildContext context, R repository) => repository;
|
||||||
|
|
||||||
/// Creates the child [Widget] to be used.
|
/// Creates the child [Widget] to be used.
|
||||||
Widget builder(BuildContext context);
|
Widget builder(BuildContext context);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => SmartProvider.repo<Repository>(
|
Widget build(BuildContext context) => SmartProvider.repo<R>(
|
||||||
context,
|
context,
|
||||||
lazy: lazy,
|
lazy: lazy,
|
||||||
enable: smart,
|
enable: smart,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
@@ -18,32 +18,31 @@ import 'package:flutter/widgets.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
/// A utility class that provides a way to create a [BlocProvider] or
|
/// A utility class that provides a way to create a [BlocProvider] or
|
||||||
/// [RepositoryProvider] with a [Bloc] or Repository that is already
|
/// [RepositoryProvider] with a bloc or Repository that is already
|
||||||
/// available in the widget tree.
|
/// available in the widget tree.
|
||||||
abstract class SmartProvider {
|
abstract class SmartProvider {
|
||||||
/// Creates a [BlocProvider] with a [Bloc] that is possibly already
|
/// Creates a [BlocProvider] with a bloc [B] that is possibly already
|
||||||
/// available in the widget tree.
|
/// available in the widget tree.
|
||||||
static BlocProvider<Bloc>
|
static BlocProvider<B> bloc<B extends BlocBase<S>, S extends Object>(
|
||||||
bloc<Bloc extends BlocBase<State>, State extends Object>(
|
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required Bloc Function(BuildContext) create,
|
required B Function(BuildContext) create,
|
||||||
required Bloc Function(BuildContext, Bloc) init,
|
required B Function(BuildContext, B) init,
|
||||||
Widget? child,
|
Widget? child,
|
||||||
bool lazy = true,
|
bool lazy = true,
|
||||||
bool enable = true,
|
bool enable = true,
|
||||||
}) {
|
}) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
final bloc = context.read<Bloc?>();
|
final bloc = context.read<B?>();
|
||||||
if (bloc != null) {
|
if (bloc != null) {
|
||||||
final b = bloc;
|
final b = bloc;
|
||||||
return BlocProvider<Bloc>.value(
|
return BlocProvider<B>.value(
|
||||||
value: init(context, b),
|
value: init(context, b),
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return BlocProvider<Bloc>(
|
return BlocProvider<B>(
|
||||||
lazy: lazy,
|
lazy: lazy,
|
||||||
create: (_) => init(context, create(context)),
|
create: (_) => init(context, create(context)),
|
||||||
child: child,
|
child: child,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2022 WYATT GROUP
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
// Please see the AUTHORS file for details.
|
// Please see the AUTHORS file for details.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: wyatt_bloc_helper
|
name: wyatt_bloc_helper
|
||||||
description: Your best friend for blocs in Flutter
|
description: Your best friend for blocs in Flutter
|
||||||
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_helper
|
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_helper
|
||||||
version: 2.0.1
|
version: 2.0.2
|
||||||
|
|
||||||
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
## 0.1.2+5
|
||||||
|
|
||||||
|
- Update a dependency to the latest release.
|
||||||
|
|
||||||
## 0.1.2+4
|
## 0.1.2+4
|
||||||
|
|
||||||
- Update a dependency to the latest release.
|
- Update a dependency to the latest release.
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ dependencies:
|
|||||||
|
|
||||||
wyatt_bloc_helper:
|
wyatt_bloc_helper:
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
version: ^2.0.1
|
version: ^2.0.2
|
||||||
wyatt_ui_layout:
|
wyatt_ui_layout:
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
version: ^0.1.2+3
|
version: ^0.1.2+3
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: wyatt_bloc_layout
|
name: wyatt_bloc_layout
|
||||||
description: Layouts based on bloc helper library
|
description: Layouts based on bloc helper library
|
||||||
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_layout
|
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_layout
|
||||||
version: 0.1.2+4
|
version: 0.1.2+5
|
||||||
|
|
||||||
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ dependencies:
|
|||||||
|
|
||||||
wyatt_bloc_helper:
|
wyatt_bloc_helper:
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
version: ^2.0.1
|
version: ^2.0.2
|
||||||
|
|
||||||
wyatt_ui_layout:
|
wyatt_ui_layout:
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
## 0.1.1+3
|
||||||
|
|
||||||
|
- Update a dependency to the latest release.
|
||||||
|
|
||||||
## 0.1.1+2
|
## 0.1.1+2
|
||||||
|
|
||||||
- **FIX**: apply dart format.
|
- **FIX**: apply dart format.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: wyatt_cloud_messaging_bloc_base
|
name: wyatt_cloud_messaging_bloc_base
|
||||||
description: A starting point for Dart libraries or applications.
|
description: A starting point for Dart libraries or applications.
|
||||||
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_notification_bloc
|
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_notification_bloc
|
||||||
version: 0.1.1+2
|
version: 0.1.1+3
|
||||||
|
|
||||||
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ dependencies:
|
|||||||
version: ^0.0.5
|
version: ^0.0.5
|
||||||
wyatt_bloc_helper:
|
wyatt_bloc_helper:
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
|
||||||
version: ^2.0.1
|
version: ^2.0.2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
## 0.1.0+3
|
||||||
|
|
||||||
|
- Update a dependency to the latest release.
|
||||||
|
|
||||||
## 0.1.0+2
|
## 0.1.0+2
|
||||||
|
|
||||||
- **REFACTOR**(cloud_messaging_bloc_firebase): update deps.
|
- **REFACTOR**(cloud_messaging_bloc_firebase): update deps.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: wyatt_cloud_messaging_bloc_firebase
|
name: wyatt_cloud_messaging_bloc_firebase
|
||||||
description: A.
|
description: A.
|
||||||
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_cloud_messaging_bloc_firebase
|
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_cloud_messaging_bloc_firebase
|
||||||
version: 0.1.0+2
|
version: 0.1.0+3
|
||||||
|
|
||||||
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ dependencies:
|
|||||||
|
|
||||||
wyatt_cloud_messaging_bloc_base:
|
wyatt_cloud_messaging_bloc_base:
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
version: ^0.1.1+2
|
version: ^0.1.1+3
|
||||||
|
|
||||||
|
|
||||||
path: ^1.8.0
|
path: ^1.8.0
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
../../.gitignore
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../.pubignore
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 WYATT GROUP
|
||||||
|
* Please see the AUTHORS file for details.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch Example",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"cwd": "example/",
|
||||||
|
"program": "lib/main.dart",
|
||||||
|
"flutterMode": "debug"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
{
|
||||||
|
"dart.runPubGetOnPubspecChanges": "never",
|
||||||
|
"bloc.newCubitTemplate.type": "equatable",
|
||||||
|
"psi-header.changes-tracking": {
|
||||||
|
"isActive": true
|
||||||
|
},
|
||||||
|
"psi-header.config": {
|
||||||
|
"blankLinesAfter": 1,
|
||||||
|
"forceToTop": true
|
||||||
|
},
|
||||||
|
"psi-header.lang-config": [
|
||||||
|
{
|
||||||
|
"beforeHeader": [
|
||||||
|
"# -*- coding:utf-8 -*-",
|
||||||
|
"#!/usr/bin/env python3"
|
||||||
|
],
|
||||||
|
"begin": "###",
|
||||||
|
"end": "###",
|
||||||
|
"language": "python",
|
||||||
|
"prefix": "# "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"beforeHeader": [
|
||||||
|
"#!/usr/bin/env sh",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"language": "shellscript",
|
||||||
|
"begin": "",
|
||||||
|
"end": "",
|
||||||
|
"prefix": "# "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"begin": "",
|
||||||
|
"end": "",
|
||||||
|
"language": "dart",
|
||||||
|
"prefix": "// "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"begin": "",
|
||||||
|
"end": "",
|
||||||
|
"language": "yaml",
|
||||||
|
"prefix": "# "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"begin": "<!--",
|
||||||
|
"end": "-->",
|
||||||
|
"language": "markdown",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"psi-header.templates": [
|
||||||
|
{
|
||||||
|
"language": "*",
|
||||||
|
"template": [
|
||||||
|
"Copyright (C) <<year>> WYATT GROUP",
|
||||||
|
"Please see the AUTHORS file for details.",
|
||||||
|
"",
|
||||||
|
"This program is free software: you can redistribute it and/or modify",
|
||||||
|
"it under the terms of the GNU General Public License as published by",
|
||||||
|
"the Free Software Foundation, either version 3 of the License, or",
|
||||||
|
"any later version.",
|
||||||
|
"",
|
||||||
|
"This program is distributed in the hope that it will be useful,",
|
||||||
|
"but WITHOUT ANY WARRANTY; without even the implied warranty of",
|
||||||
|
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
|
||||||
|
"GNU General Public License for more details.",
|
||||||
|
"",
|
||||||
|
"You should have received a copy of the GNU General Public License",
|
||||||
|
"along with this program. If not, see <https://www.gnu.org/licenses/>."
|
||||||
|
],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../AUTHORS
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
## 1.0.0
|
||||||
|
|
||||||
|
- Initial version.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../LICENSE
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<!--
|
||||||
|
* Copyright (C) 2023 WYATT GROUP
|
||||||
|
* Please see the AUTHORS file for details.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
# Flutter - Wyatt Go Router
|
||||||
|
|
||||||
|
<p align="left">
|
||||||
|
<a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a>
|
||||||
|
<img src="https://img.shields.io/badge/SDK-Flutter-blue?style=flat-square" alt="SDK: Flutter" />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
GoRouter Enhancements for Flutter
|
||||||
|
|
||||||
|
This package provides a set of utilities to help you use the [GoRouter](https://pub.dev/packages/go_router) package.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* PageProtection extension to add a protection to a page
|
||||||
|
* currentRoute method to get the current route anywhere in the app
|
||||||
|
* GoRouterRefreshStream to refresh the router when needed
|
||||||
|
* RouteBase flattenization to get a list of all the routes in the router
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
If you want to protect a page, you can use the PageProtection extension:
|
||||||
|
|
||||||
|
```dart
|
||||||
|
GoRoute(
|
||||||
|
path: '/sign_in',
|
||||||
|
...
|
||||||
|
)..setPublic(),
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to get the current route, you can use the currentRoute method:
|
||||||
|
|
||||||
|
```dart
|
||||||
|
final route = GoRouter.of(context).currentRoute;
|
||||||
|
// or
|
||||||
|
final route = context.currentRoute;
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to refresh the router, you can use the GoRouterRefreshStream:
|
||||||
|
|
||||||
|
```dart
|
||||||
|
GoRouterRefreshStream(
|
||||||
|
context.read<AuthenticationCubit<Session>>().stream,
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to get a list of all the routes in the router, you can use the RouteBase flattenization:
|
||||||
|
|
||||||
|
```dart
|
||||||
|
final routes = GoRouter.of(context).flattenedRoutes;
|
||||||
|
```
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
include: package:wyatt_analysis/analysis_options.flutter.yaml
|
||||||
|
|
||||||
|
analyzer:
|
||||||
|
plugins:
|
||||||
|
- dart_code_linter
|
||||||
|
|
||||||
|
dart_code_linter:
|
||||||
|
anti-patterns:
|
||||||
|
- long-method
|
||||||
|
- long-parameter-list
|
||||||
|
metrics:
|
||||||
|
cyclomatic-complexity: 20
|
||||||
|
maximum-nesting-level: 5
|
||||||
|
number-of-parameters: 10
|
||||||
|
source-lines-of-code: 400
|
||||||
|
metrics-exclude:
|
||||||
|
- test/**
|
||||||
|
rules:
|
||||||
|
- newline-before-return
|
||||||
|
- no-boolean-literal-compare
|
||||||
|
- no-empty-block
|
||||||
|
- prefer-trailing-comma
|
||||||
|
- prefer-conditional-expressions
|
||||||
|
- no-equal-then-else
|
||||||
|
- avoid-border-all
|
||||||
|
- prefer-const-border-radius
|
||||||
|
- prefer-using-list-view
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# Miscellaneous
|
||||||
|
*.class
|
||||||
|
*.log
|
||||||
|
*.pyc
|
||||||
|
*.swp
|
||||||
|
.DS_Store
|
||||||
|
.atom/
|
||||||
|
.buildlog/
|
||||||
|
.history
|
||||||
|
.svn/
|
||||||
|
migrate_working_dir/
|
||||||
|
|
||||||
|
# IntelliJ related
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# The .vscode folder contains launch configuration and tasks you configure in
|
||||||
|
# VS Code which you may wish to be included in version control, so this line
|
||||||
|
# is commented out by default.
|
||||||
|
#.vscode/
|
||||||
|
|
||||||
|
# Flutter/Dart/Pub related
|
||||||
|
**/doc/api/
|
||||||
|
**/ios/Flutter/.last_build_id
|
||||||
|
.dart_tool/
|
||||||
|
.flutter-plugins
|
||||||
|
.flutter-plugins-dependencies
|
||||||
|
.packages
|
||||||
|
.pub-cache/
|
||||||
|
.pub/
|
||||||
|
/build/
|
||||||
|
|
||||||
|
# Symbolication related
|
||||||
|
app.*.symbols
|
||||||
|
|
||||||
|
# Obfuscation related
|
||||||
|
app.*.map.json
|
||||||
|
|
||||||
|
# Android Studio will place build artifacts here
|
||||||
|
/android/app/debug
|
||||||
|
/android/app/profile
|
||||||
|
/android/app/release
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# This file tracks properties of this Flutter project.
|
||||||
|
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||||
|
#
|
||||||
|
# This file should be version controlled and should not be manually edited.
|
||||||
|
|
||||||
|
version:
|
||||||
|
revision: "d211f42860350d914a5ad8102f9ec32764dc6d06"
|
||||||
|
channel: "stable"
|
||||||
|
|
||||||
|
project_type: app
|
||||||
|
|
||||||
|
# Tracks metadata for the flutter migrate command
|
||||||
|
migration:
|
||||||
|
platforms:
|
||||||
|
- platform: root
|
||||||
|
create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
|
||||||
|
base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
|
||||||
|
- platform: android
|
||||||
|
create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
|
||||||
|
base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
|
||||||
|
|
||||||
|
# User provided section
|
||||||
|
|
||||||
|
# List of Local paths (relative to this file) that should be
|
||||||
|
# ignored by the migrate tool.
|
||||||
|
#
|
||||||
|
# Files that are not part of the templates will be ignored by default.
|
||||||
|
unmanaged_files:
|
||||||
|
- 'lib/main.dart'
|
||||||
|
- 'ios/Runner.xcodeproj/project.pbxproj'
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# 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://docs.flutter.dev/get-started/codelab)
|
||||||
|
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
||||||
|
|
||||||
|
For help getting started with Flutter development, view the
|
||||||
|
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
||||||
|
samples, guidance on mobile development, and a full API reference.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
include: package:wyatt_analysis/analysis_options.flutter.yaml
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
gradle-wrapper.jar
|
||||||
|
/.gradle
|
||||||
|
/captures/
|
||||||
|
/gradlew
|
||||||
|
/gradlew.bat
|
||||||
|
/local.properties
|
||||||
|
GeneratedPluginRegistrant.java
|
||||||
|
|
||||||
|
# Remember to never publicly share your keystore.
|
||||||
|
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
|
||||||
|
key.properties
|
||||||
|
**/*.keystore
|
||||||
|
**/*.jks
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
plugins {
|
||||||
|
id "com.android.application"
|
||||||
|
id "kotlin-android"
|
||||||
|
id "dev.flutter.flutter-gradle-plugin"
|
||||||
|
}
|
||||||
|
|
||||||
|
def localProperties = new Properties()
|
||||||
|
def localPropertiesFile = rootProject.file('local.properties')
|
||||||
|
if (localPropertiesFile.exists()) {
|
||||||
|
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||||
|
localProperties.load(reader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||||
|
if (flutterVersionCode == null) {
|
||||||
|
flutterVersionCode = '1'
|
||||||
|
}
|
||||||
|
|
||||||
|
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||||
|
if (flutterVersionName == null) {
|
||||||
|
flutterVersionName = '1.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace "com.example.example"
|
||||||
|
compileSdkVersion flutter.compileSdkVersion
|
||||||
|
ndkVersion flutter.ndkVersion
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '1.8'
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
|
applicationId "com.example.example"
|
||||||
|
// You can update the following values to match your application needs.
|
||||||
|
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||||
|
minSdkVersion flutter.minSdkVersion
|
||||||
|
targetSdkVersion flutter.targetSdkVersion
|
||||||
|
versionCode flutterVersionCode.toInteger()
|
||||||
|
versionName flutterVersionName
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
// TODO: Add your own signing config for the release build.
|
||||||
|
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||||
|
signingConfig signingConfigs.debug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flutter {
|
||||||
|
source '../..'
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- The INTERNET permission is required for development. Specifically,
|
||||||
|
the Flutter tool needs it to communicate with the running application
|
||||||
|
to allow setting breakpoints, to provide hot reload, etc.
|
||||||
|
-->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<application
|
||||||
|
android:label="example"
|
||||||
|
android:name="${applicationName}"
|
||||||
|
android:icon="@mipmap/ic_launcher">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:launchMode="singleTop"
|
||||||
|
android:theme="@style/LaunchTheme"
|
||||||
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||||
|
android:hardwareAccelerated="true"
|
||||||
|
android:windowSoftInputMode="adjustResize">
|
||||||
|
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||||
|
the Android process has started. This theme is visible to the user
|
||||||
|
while the Flutter UI initializes. After that, this theme continues
|
||||||
|
to determine the Window background behind the Flutter UI. -->
|
||||||
|
<meta-data
|
||||||
|
android:name="io.flutter.embedding.android.NormalTheme"
|
||||||
|
android:resource="@style/NormalTheme"
|
||||||
|
/>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<!-- Don't delete the meta-data below.
|
||||||
|
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||||
|
<meta-data
|
||||||
|
android:name="flutterEmbedding"
|
||||||
|
android:value="2" />
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.example.example
|
||||||
|
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
||||||
|
class MainActivity: FlutterActivity() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Modify this file to customize your launch splash screen -->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="?android:colorBackground" />
|
||||||
|
|
||||||
|
<!-- You can insert your own image assets here -->
|
||||||
|
<!-- <item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@mipmap/launch_image" />
|
||||||
|
</item> -->
|
||||||
|
</layer-list>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Modify this file to customize your launch splash screen -->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@android:color/white" />
|
||||||
|
|
||||||
|
<!-- You can insert your own image assets here -->
|
||||||
|
<!-- <item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@mipmap/launch_image" />
|
||||||
|
</item> -->
|
||||||
|
</layer-list>
|
||||||
|
After Width: | Height: | Size: 544 B |
|
After Width: | Height: | Size: 442 B |
|
After Width: | Height: | Size: 721 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
|
||||||
|
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
<!-- Show a splash screen on the activity. Automatically removed when
|
||||||
|
the Flutter engine draws its first frame -->
|
||||||
|
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||||
|
</style>
|
||||||
|
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||||
|
This theme determines the color of the Android Window while your
|
||||||
|
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||||
|
running.
|
||||||
|
|
||||||
|
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||||
|
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
<item name="android:windowBackground">?android:colorBackground</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
|
||||||
|
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
|
<!-- Show a splash screen on the activity. Automatically removed when
|
||||||
|
the Flutter engine draws its first frame -->
|
||||||
|
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||||
|
</style>
|
||||||
|
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||||
|
This theme determines the color of the Android Window while your
|
||||||
|
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||||
|
running.
|
||||||
|
|
||||||
|
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||||
|
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
|
<item name="android:windowBackground">?android:colorBackground</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- The INTERNET permission is required for development. Specifically,
|
||||||
|
the Flutter tool needs it to communicate with the running application
|
||||||
|
to allow setting breakpoints, to provide hot reload, etc.
|
||||||
|
-->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.7.10'
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:7.3.0'
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.buildDir = '../build'
|
||||||
|
subprojects {
|
||||||
|
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||||
|
}
|
||||||
|
subprojects {
|
||||||
|
project.evaluationDependsOn(':app')
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("clean", Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
|
android.useAndroidX=true
|
||||||
|
android.enableJetifier=true
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
pluginManagement {
|
||||||
|
def flutterSdkPath = {
|
||||||
|
def properties = new Properties()
|
||||||
|
file("local.properties").withInputStream { properties.load(it) }
|
||||||
|
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||||
|
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||||
|
return flutterSdkPath
|
||||||
|
}
|
||||||
|
settings.ext.flutterSdkPath = flutterSdkPath()
|
||||||
|
|
||||||
|
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
include ":app"
|
||||||
|
|
||||||
|
apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:wyatt_go_router/wyatt_go_router.dart';
|
||||||
|
import 'package:wyatt_go_router_example/bottom_bar.dart';
|
||||||
|
import 'package:wyatt_go_router_example/page_a.dart';
|
||||||
|
import 'package:wyatt_go_router_example/page_b.dart';
|
||||||
|
import 'package:wyatt_go_router_example/page_c.dart';
|
||||||
|
|
||||||
|
abstract class AppRouter {
|
||||||
|
/// Default transition for all pages
|
||||||
|
static Page<void> defaultTransition(
|
||||||
|
BuildContext context,
|
||||||
|
GoRouterState state,
|
||||||
|
Widget child,
|
||||||
|
) =>
|
||||||
|
CupertinoPage<void>(key: state.pageKey, child: child);
|
||||||
|
|
||||||
|
/// Disable transition animation
|
||||||
|
static Page<void> noTransition(
|
||||||
|
BuildContext context,
|
||||||
|
GoRouterState state,
|
||||||
|
Widget child,
|
||||||
|
) =>
|
||||||
|
NoTransitionPage(key: state.pageKey, child: child);
|
||||||
|
|
||||||
|
static final GlobalKey<NavigatorState> rootNavigatorKey =
|
||||||
|
GlobalKey<NavigatorState>();
|
||||||
|
static final GlobalKey<NavigatorState> shellNavigatorKey =
|
||||||
|
GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
|
/// Defines GoRoute routes.
|
||||||
|
static final List<RouteBase> routes = [
|
||||||
|
ShellRoute(
|
||||||
|
navigatorKey: shellNavigatorKey,
|
||||||
|
builder: (context, state, child) {
|
||||||
|
final currentRoute = context.currentRoute;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(
|
||||||
|
currentRoute.name ?? 'Unknown',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: child,
|
||||||
|
bottomNavigationBar: BottomBar(
|
||||||
|
currentRoute: currentRoute,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
routes: [
|
||||||
|
GoRoute(
|
||||||
|
path: '/page-a',
|
||||||
|
name: 'A',
|
||||||
|
pageBuilder: (context, state) => noTransition(
|
||||||
|
context,
|
||||||
|
state,
|
||||||
|
const PageA(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/page-b',
|
||||||
|
name: 'B',
|
||||||
|
pageBuilder: (context, state) => noTransition(
|
||||||
|
context,
|
||||||
|
state,
|
||||||
|
const PageB(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/page-c',
|
||||||
|
name: 'C',
|
||||||
|
parentNavigatorKey: rootNavigatorKey,
|
||||||
|
pageBuilder: (context, state) => defaultTransition(
|
||||||
|
context,
|
||||||
|
state,
|
||||||
|
const PageC(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
static GoRouter? _router;
|
||||||
|
|
||||||
|
/// Returns the router.
|
||||||
|
static GoRouter routerOf(BuildContext context) => _router ??= GoRouter(
|
||||||
|
initialLocation: '/page-a',
|
||||||
|
routes: AppRouter.routes,
|
||||||
|
navigatorKey: rootNavigatorKey,
|
||||||
|
debugLogDiagnostics: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:wyatt_go_router/wyatt_go_router.dart';
|
||||||
|
|
||||||
|
class BottomBar extends StatelessWidget {
|
||||||
|
const BottomBar({
|
||||||
|
required this.currentRoute,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final GoRoute currentRoute;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => BottomNavigationBar(
|
||||||
|
items: const [
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(Icons.home),
|
||||||
|
label: 'Home',
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(Icons.settings),
|
||||||
|
label: 'Settings',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
currentIndex: (currentRoute.name == 'A') ? 0 : 1,
|
||||||
|
onTap: (index) => switch (index) {
|
||||||
|
0 => context.goNamed('A'),
|
||||||
|
1 => context.goNamed('B'),
|
||||||
|
_ => throw Exception('Invalid index: $index'),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:wyatt_go_router_example/app_router.dart';
|
||||||
|
|
||||||
|
void main(List<String> args) {
|
||||||
|
runApp(const App());
|
||||||
|
}
|
||||||
|
|
||||||
|
class App extends StatelessWidget {
|
||||||
|
const App({super.key});
|
||||||
|
|
||||||
|
static const String title = 'Wyatt Go Router Example';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => MaterialApp.router(
|
||||||
|
title: title,
|
||||||
|
routerConfig: AppRouter.routerOf(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:wyatt_go_router/wyatt_go_router.dart';
|
||||||
|
|
||||||
|
class PageA extends StatelessWidget {
|
||||||
|
const PageA({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => Center(
|
||||||
|
child: Text(
|
||||||
|
'Page A: ${context.currentRoute}',
|
||||||
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:wyatt_go_router/wyatt_go_router.dart';
|
||||||
|
|
||||||
|
class PageB extends StatelessWidget {
|
||||||
|
const PageB({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Page B: ${context.currentRoute}',
|
||||||
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => context.pushNamed('C'),
|
||||||
|
child: const Text('Go to Page C'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:wyatt_go_router/wyatt_go_router.dart';
|
||||||
|
|
||||||
|
class PageC extends StatelessWidget {
|
||||||
|
const PageC({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Page C'),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Text(
|
||||||
|
'Page C: ${context.currentRoute}',
|
||||||
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
name: wyatt_go_router_example
|
||||||
|
description: A new Flutter project.
|
||||||
|
version: 1.0.0
|
||||||
|
|
||||||
|
publish_to: "none"
|
||||||
|
|
||||||
|
environment:
|
||||||
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
flutter: { sdk: flutter }
|
||||||
|
|
||||||
|
wyatt_go_router:
|
||||||
|
path: "../"
|
||||||
|
|
||||||
|
dev_dependencies:
|
||||||
|
flutter_test: { sdk: flutter }
|
||||||
|
|
||||||
|
wyatt_analysis:
|
||||||
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
|
version: ^2.6.1
|
||||||
|
|
||||||
|
# The following section is specific to Flutter.
|
||||||
|
flutter:
|
||||||
|
uses-material-design: true
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
|
After Width: | Height: | Size: 917 B |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,59 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!--
|
||||||
|
If you are serving your web app in a path other than the root, change the
|
||||||
|
href value below to reflect the base path you are serving from.
|
||||||
|
|
||||||
|
The path provided below has to start and end with a slash "/" in order for
|
||||||
|
it to work correctly.
|
||||||
|
|
||||||
|
For more details:
|
||||||
|
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
|
||||||
|
|
||||||
|
This is a placeholder for base href that will be replaced by the value of
|
||||||
|
the `--base-href` argument provided to `flutter build`.
|
||||||
|
-->
|
||||||
|
<base href="$FLUTTER_BASE_HREF">
|
||||||
|
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||||
|
<meta name="description" content="A new Flutter project.">
|
||||||
|
|
||||||
|
<!-- iOS meta tags & icons -->
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
|
<meta name="apple-mobile-web-app-title" content="example">
|
||||||
|
<link rel="apple-touch-icon" href="icons/Icon-192.png">
|
||||||
|
|
||||||
|
<!-- Favicon -->
|
||||||
|
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||||
|
|
||||||
|
<title>example</title>
|
||||||
|
<link rel="manifest" href="manifest.json">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// The value below is injected by flutter build, do not touch.
|
||||||
|
var serviceWorkerVersion = null;
|
||||||
|
</script>
|
||||||
|
<!-- This script adds the flutter initialization JS code -->
|
||||||
|
<script src="flutter.js" defer></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
window.addEventListener('load', function(ev) {
|
||||||
|
// Download main.dart.js
|
||||||
|
_flutter.loader.loadEntrypoint({
|
||||||
|
serviceWorker: {
|
||||||
|
serviceWorkerVersion: serviceWorkerVersion,
|
||||||
|
},
|
||||||
|
onEntrypointLoaded: function(engineInitializer) {
|
||||||
|
engineInitializer.initializeEngine().then(function(appRunner) {
|
||||||
|
appRunner.runApp();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "example",
|
||||||
|
"short_name": "example",
|
||||||
|
"start_url": ".",
|
||||||
|
"display": "standalone",
|
||||||
|
"background_color": "#0175C2",
|
||||||
|
"theme_color": "#0175C2",
|
||||||
|
"description": "A new Flutter project.",
|
||||||
|
"orientation": "portrait-primary",
|
||||||
|
"prefer_related_applications": false,
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "icons/Icon-192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/Icon-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/Icon-maskable-192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icons/Icon-maskable-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/// {@template}
|
||||||
|
/// A enum that defines the protection of a page.
|
||||||
|
/// {@endtemplate}
|
||||||
|
enum PageProtection {
|
||||||
|
/// The page can be accessed without authentication.
|
||||||
|
public,
|
||||||
|
|
||||||
|
/// The page can only be accessed with authentication.
|
||||||
|
protected,
|
||||||
|
|
||||||
|
/// The page protection is unknown, and the default one should be used.
|
||||||
|
none,
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:wyatt_go_router/wyatt_go_router.dart';
|
||||||
|
|
||||||
|
extension BuildContextExtension on BuildContext {
|
||||||
|
GoRoute get currentRoute => GoRouter.of(this).currentRoute;
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:wyatt_go_router/src/core/enums/page_protection.dart';
|
||||||
|
|
||||||
|
/// Defines if a GoRoute is public or not.
|
||||||
|
///
|
||||||
|
/// By default, all routes are in the [PageProtection.none] state.
|
||||||
|
extension GoRouteExtension on GoRoute {
|
||||||
|
static final _protection = Expando<PageProtection>();
|
||||||
|
|
||||||
|
/// Returns `true` if the route is public.
|
||||||
|
bool get isPublic => _protection[this] == PageProtection.public;
|
||||||
|
|
||||||
|
/// Returns `true` if the route is protected.
|
||||||
|
bool get isProtected => _protection[this] == PageProtection.protected;
|
||||||
|
|
||||||
|
/// Returns `true` if the route is neither public nor protected.
|
||||||
|
/// This is the default state.
|
||||||
|
bool get isNone => _protection[this] == PageProtection.none;
|
||||||
|
|
||||||
|
/// Sets the route to be public.
|
||||||
|
/// This is useful for routes that should be accessible
|
||||||
|
/// without authentication.
|
||||||
|
/// ```dart
|
||||||
|
/// GoRoute(
|
||||||
|
/// path: '/sign_in',
|
||||||
|
/// ...
|
||||||
|
/// )..setPublic(),
|
||||||
|
/// ```
|
||||||
|
void setPublic() => _protection[this] = PageProtection.public;
|
||||||
|
|
||||||
|
/// Sets the route to be protected.
|
||||||
|
/// This is useful for routes that should only be accessible
|
||||||
|
/// with authentication.
|
||||||
|
void setProtected() => _protection[this] = PageProtection.protected;
|
||||||
|
|
||||||
|
PageProtection get protection => _protection[this] ?? PageProtection.none;
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:wyatt_go_router/src/core/extensions/go_route_extension.dart';
|
||||||
|
|
||||||
|
extension GoRouteIterableExtension on Iterable<GoRoute> {
|
||||||
|
/// Returns a list of public routes.
|
||||||
|
List<GoRoute> get publicRoutes =>
|
||||||
|
where((route) => route.isPublic).toList(growable: false);
|
||||||
|
|
||||||
|
/// Returns a list of protected routes.
|
||||||
|
List<GoRoute> get protectedRoutes =>
|
||||||
|
where((route) => route.isProtected).toList(growable: false);
|
||||||
|
|
||||||
|
/// Returns a list of routes that are neither public nor protected.
|
||||||
|
List<GoRoute> get noneRoutes =>
|
||||||
|
where((route) => route.isNone).toList(growable: false);
|
||||||
|
|
||||||
|
/// Returns a go route from its name.
|
||||||
|
///
|
||||||
|
/// If no route is found, a [StateError] is thrown.
|
||||||
|
GoRoute fromName(String name) => firstWhere((route) => route.name == name);
|
||||||
|
|
||||||
|
/// Returns a go route from its path.
|
||||||
|
///
|
||||||
|
/// If no route is found, a [StateError] is thrown.
|
||||||
|
GoRoute fromPath(String path) => firstWhere((route) => route.path == path);
|
||||||
|
|
||||||
|
/// Returns a go route from its name or null if no route is found.
|
||||||
|
GoRoute? fromNameOrNull(String name) {
|
||||||
|
if (any((route) => route.name == name)) {
|
||||||
|
return fromName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a go route from its path or null if no route is found.
|
||||||
|
GoRoute? fromPathOrNull(String path) {
|
||||||
|
if (any((route) => route.path == path)) {
|
||||||
|
return fromPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a go route from its name, or null if no route is found.
|
||||||
|
///
|
||||||
|
/// This is a shorthand for [fromNameOrNull].
|
||||||
|
GoRoute? operator [](String name) => fromNameOrNull(name);
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:wyatt_go_router/wyatt_go_router.dart';
|
||||||
|
|
||||||
|
extension GoRouterExtension on GoRouter {
|
||||||
|
List<GoRoute> get flattenedRoutes => configuration.routes
|
||||||
|
.map((route) => route.flatten())
|
||||||
|
.expand(
|
||||||
|
(routeList) => routeList,
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
/// Returns the current route.
|
||||||
|
GoRoute get currentRoute =>
|
||||||
|
flattenedRoutes.fromPath(routeInformationProvider.value.uri.path);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
|
/// Flatten the [GoRoute] tree.
|
||||||
|
extension RouteBaseExtension on RouteBase {
|
||||||
|
/// Flatten a [GoRoute] or [ShellRoute] into a list of [GoRoute]s.
|
||||||
|
/// - If the current route is a [GoRoute], it is added to the list.
|
||||||
|
/// - If the current route is a [ShellRoute], all of its child routes are
|
||||||
|
/// flattened and added to the list.
|
||||||
|
List<GoRoute> flatten() {
|
||||||
|
final List<GoRoute> routes = [];
|
||||||
|
if (this is GoRoute) {
|
||||||
|
routes.add(this as GoRoute);
|
||||||
|
} else if (this is ShellRoute) {
|
||||||
|
routes.addAll(
|
||||||
|
(this as ShellRoute)
|
||||||
|
.routes
|
||||||
|
.map((route) => route.flatten())
|
||||||
|
.expand((routeList) => routeList),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return routes;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
|
/// {@template go_router_refresh_stream}
|
||||||
|
/// A [ChangeNotifier] that notifies its listeners when a stream emits a value.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class GoRouterRefreshStream extends ChangeNotifier {
|
||||||
|
/// {@macro go_router_refresh_stream}
|
||||||
|
GoRouterRefreshStream(Stream<dynamic> stream) {
|
||||||
|
notifyListeners();
|
||||||
|
_subscription = stream.asBroadcastStream().listen(
|
||||||
|
(dynamic _) => notifyListeners(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
late final StreamSubscription<dynamic> _subscription;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_subscription.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
export 'core/enums/page_protection.dart';
|
||||||
|
export 'core/extensions/build_context_extension.dart';
|
||||||
|
export 'core/extensions/go_route_extension.dart';
|
||||||
|
export 'core/extensions/go_route_iterable_extension.dart';
|
||||||
|
export 'core/extensions/go_router_extension.dart';
|
||||||
|
export 'core/extensions/route_base_extension.dart';
|
||||||
|
export 'core/go_router_refresh_stream.dart';
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/// GoRouter enhancements
|
||||||
|
///
|
||||||
|
/// This library provides enhancements to the GoRouter package.
|
||||||
|
/// It also exports the GoRouter package.
|
||||||
|
library wyatt_go_router;
|
||||||
|
|
||||||
|
export 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
|
export 'src/wyatt_go_router.dart';
|
||||||