1️⃣ flutter pub add guards
2️⃣ Create lib/core/guards/base.dart with your project settings
abstract base class MyProjectGuard extends GuardBase {
//none of the project guards will require a special persistenceDelegate, so we cut down that possibility project-wide with this code
MyProjectGuard() : super(persistenceDelegate: null);
}3️⃣ Create your guards like lib/core/guards/login_guard.dart
class GuardLogin extends MyProjectGuard{
///Implement every field
}
4️⃣ Define your project's guards in a GuardsSystem of your project:
class MyProjectGuards extends Guards {
MyProjectGuards({required this.gpsActive})
: super(persistenceDelegate: null, initialGuards: [gpsActive]);
// define the guards you want to use in your app like this as much as possible for simplicity and ease of use
final GuardGpsActive gpsActive;
// if for some reason you want to have a guard that can't be initialized at the start of the app, you can use this technique instead
GuardGeolocationPermission get geolocationPermission =>
getGuardByGuardIdentifier('geolocation_permission');
}5️⃣ Create the pages that will be used for redirection when guards aren't satisfied
🔀 This package tries to be agnostic in the routing solution of your choice, but here are the vicissitudes for every solution you could have
6️⃣ Add your guard system to your MaterialApp router
TBD
TBD
For first time users, install the very_good_cli:
dart pub global activate very_good_cliTo run all unit tests:
very_good test --coverageTo view the generated coverage report you can use lcov.
# Generate Coverage Report
genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
open coverage/index.html- Import the package
- Define the guards you will use in a
guards/dir on your app's dir - Include a
Guards.init()in your bootstrap with the PersistenceDelegate in charge of storing in the app memory-on-disk the guards status - Include the guards in your router
- checkeo de estado de las guardas
- asd