rightify 0.1.0 copy "rightify: ^0.1.0" to clipboard
rightify: ^0.1.0 copied to clipboard

A lightweight, backend-agnostic rights engine for Flutter.

rightify #

A lightweight, backend-agnostic rights engine for Flutter apps.


โœจ Why this library? #

Most Flutter apps handle payments via Stripe, RevenueCat, or app stores, but feature access logic is often rewritten for every app.

rightify focuses on one simple problem:

"Can this user perform this action right now?"

No enums, no business logic, no backend coupling.


๐Ÿš€ Features #

  • Generic rights engine (String-based)
  • Action โ†’ minimum required level rules
  • Ordered rights hierarchy
  • Local cache (SharedPreferences)
  • Optional remote source (JSON)
  • Simple API: canPerform(action)
  • Fully testable

โŒ What this library does NOT do #

  • Payment processing
  • Subscription validation
  • Backend security
  • Fraud prevention

Always re-check permissions on the backend.


๐Ÿ“ฆ Installation #

dependencies:
  rightify: ^0.1.0

๐Ÿง  Core concepts #

Actions #

Actions are strings defined by the app developer:

const exportPdf = 'export_pdf';
const createInvoice = 'create_invoice';

Rights levels #

Also strings, fully controlled by the app:

const free = 'free';
const premium = 'premium';
const gold = 'gold';

Rights hierarchy #

Order matters:

final hierarchy = ['free', 'premium', 'gold'];

Higher index = more permissions.

Action rules #

Define the minimum level required for each action:

final rules = {
  exportPdf: gold,
  createInvoice: premium,
};

๐Ÿ”ง Initialization #

await Rightify.initialize(
  hierarchy: hierarchy,
  rules: rules,
  localSource: SharedPrefsRightsSource(),
  remoteSource: RemoteRightsSource(() => api.get('/me/rights')),
);

โœ… Checking permissions #

if (Rightify.canPerform(exportPdf)) {
  exportPdf();
} else {
  showPaywall();
}

๐Ÿ”„ Updating user level #

await Rightify.setLevel(gold);

๐ŸŒ Remote JSON format example #

{
  "right_level": "gold"
}

๐Ÿงช Testing #

  • Fully testable rights engine
  • Fake sources for local/remote
  • No Flutter UI dependencies

Check the test/ folder for examples.


๐Ÿ›ฃ Roadmap #

  • Expiring rights
  • Free trials
  • Scoped actions
  • Analytics hooks
  • RevenueCat / Stripe adapters

๐Ÿ“„ License #

MIT

0
likes
110
points
97
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight, backend-agnostic rights engine for Flutter.

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface, shared_preferences

More

Packages that depend on rightify

Packages that implement rightify