Created
November 13, 2020 05:36
-
-
Save ampersanda/43ee0665bde93d49b445c3c907f8458a to your computer and use it in GitHub Desktop.
Manage single loading state of Provider's Notifier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mixin SingleLoadingStoreMixin on ChangeNotifier { | |
/// Loading state | |
bool _isLoading = false; | |
/// Loading getter | |
bool get isLoading => _isLoading; | |
/// Set loading state to true | |
void $showLoading() { | |
if (!_isLoading) { | |
_isLoading = true; | |
notifyListeners(); | |
} | |
} | |
/// Set loading state to true | |
void $hideLoading() { | |
if (_isLoading) { | |
_isLoading = false; | |
notifyListeners(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment