https://github.com/devmuaz/change-notifier-base
A change notifier base class which helps reducing boilerplate code
https://github.com/devmuaz/change-notifier-base
flutter provider riverpod
Last synced: 3 months ago
JSON representation
A change notifier base class which helps reducing boilerplate code
- Host: GitHub
- URL: https://github.com/devmuaz/change-notifier-base
- Owner: devmuaz
- License: mit
- Created: 2022-07-19T19:19:04.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-27T09:15:34.000Z (over 1 year ago)
- Last Synced: 2025-01-29T22:29:08.612Z (5 months ago)
- Topics: flutter, provider, riverpod
- Language: C++
- Homepage:
- Size: 207 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## BaseChangeNotifier
A change notifier base class which helps reducing boilerplate code used in the
`ChangeNotifier` classes## Usage
```dart
class AuthProvider extends BaseChangeNotifier {
final AuthRepository _authRepository;AuthProvider(this._authRepository);
Future login({required LoginRequest request}) async {
await run(() async {
final response = await _apiRepository.login(request);if (response.isSuccessfull) {
/// [response.data] is a [AuthResponse] type
data = response.data;
} else {
/// [response.error] is a [DioException] type
error = response.error;
}
}, loadingType: LoadingType.fullscreenLoading);
}/// Ignore overriding it if the [loadingType] is [loadingType.stateLoading]
@override
void onShowFullScreenLoadingDialog() {
showFullScreenLoadingDialog();
}/// Ignore overriding it if the [loadingType] is [loadingType.stateLoading]
@override
void onHideFullScreenLoadingDialog() {
hideFullScreenLoadingDialog();
}
}
```## Medium articles by the author
You can always read the articles I write on my [devmuaz](https://devmuaz.medium.com/) account which I write pretty great flutter content out there.
## Contributions & Support
Issues and pull requests are always welcome 😄
If you find this package useful for you and liked it, give it a like ❤️ and star the repo ⭐️ it would mean a lot!
## License
**MIT**