any_state 0.0.4+1 copy "any_state: ^0.0.4+1" to clipboard
any_state: ^0.0.4+1 copied to clipboard

Simple yet easily extended state class declaration that supports localizations

Any State #

Simple state class declaration that supports localizations

Features #

  • Simple state object that inherently supports localizations
  • Function translate will deliver the message in the current app language
  • Display what went wrong in the UI with ease (or success message)

Getting started #

  • Add this to your package's pubspec.yaml file:
dependencies:
  any_state: ^0.0.1

Usage #

Create your own state class by extending AnyState and implement the toString method to return the desired message.

    class NetworkFailure extends AnyFailure {
      NetworkFailure.badResponse() : super('network_failure_bad_response');

      @override
      String toString(AppLocalizations l10n) {
        if(this is NetworkFailure.badResponse) {
          return l10n.networkFailureBadResponse; // <--- Your translation key
        }
        return super.toString(l10n);
      }
    }

Additional information #

Feel free to try it out and let me know what you think. I'm open to suggestions and improvements. Contact me at my email

0
likes
0
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

Simple yet easily extended state class declaration that supports localizations

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

equatable, flutter

More

Packages that depend on any_state