reactive_orm 0.0.5 copy "reactive_orm: ^0.0.5" to clipboard
reactive_orm: ^0.0.5 copied to clipboard

A lightweight reactive ORM-style state management package for Flutter.

reactive_orm #

Pub Version | License: MIT

A lightweight, reactive ORM-style state management package for Flutter. Update your UI automatically when model properties change โ€” without setState, streams, or boilerplate.

Version: 0.0.5 โ€“ Stable


๐ŸŽฌ Demo #

Reactive_ORM Demo


โœจ Core Philosophy #

  • Models are plain Dart objects.
  • State changes happen via normal field mutation.
  • UI reacts automatically, with optional field-specific reactivity.
  • No ChangeNotifier, providers, streams, or extra boilerplate.

โœจ Features #

  • โœ… Reactive models with automatic UI updates
  • โœ… Object-wise reactivity (entire model rebuilds)
  • โœ… Field-wise reactivity (only selected fields rebuild)
  • โœ… Nested & shared models supported
  • โœ… Multiple widgets can listen to the same model

๐Ÿ†š Comparison #

Feature ValueNotifier reactive_orm
Observes a single field? Yes (one notifier per field) Yes (field-wise) + whole object
Field assignment syntax notifier.value = newValue model.field = newValue (auto-notifies)
Multiple widgets listening Manual wiring Automatic
Nested models Manual Built-in (addNested)
Boilerplate Medium โ†’ High Minimal, ORM-style
Ideal for Simple values Complex reactive models

๐Ÿš€ Getting Started #

Installation #

dependencies:
  reactive_orm: ^0.0.4


๐Ÿงฉ Basic Usage
1๏ธโƒฃ Create a Reactive Model
import 'package:reactive_orm/reactive_orm.dart';

class Task extends ReactiveModel {
  String _title;
  bool _completed = false;
  String _status = "Idle";

  Task({required String title}) : _title = title;

  String get title => _title;
  set title(String value) {
    if (_title != value) {
      _title = value;
      notifyListeners('title');
    }
  }

  bool get completed => _completed;
  set completed(bool value) {
    if (_completed != value) {
      _completed = value;
      notifyListeners('completed');
    }
  }

  String get status => _status;
  set status(String value) {
    if (_status != value) {
      _status = value;
      notifyListeners('status');
    }
  }
}


2๏ธโƒฃ Object-wise Reactivity (Whole Object)
Any field change rebuilds the widget:

final task = Task(title: "Object-wise");

ReactiveBuilder<Task>(
  model: task,
  builder: (t) => ListTile(
    title: Text(t.title),
    subtitle: Text(t.status),
    trailing: Checkbox(
      value: t.completed,
      onChanged: (v) => t.completed = v!,
    ),
  ),
);


3๏ธโƒฃ Field-wise Reactivity (Optimized)
Widget rebuilds only when specified fields change:

final task = Task(title: "Field-wise");

ReactiveBuilder<Task>(
  model: task,
  fields: ['completed', 'status'],
  builder: (t) => ListTile(
    title: Text(t.title),
    subtitle: Text(t.status),
    trailing: Checkbox(
      value: t.completed,
      onChanged: (v) => t.completed = v!,
    ),
  ),
);
- Rebuilds only when completed or status changes.
- Changes to other fields are ignored.

๐Ÿ”— Relationship Patterns
1-> Many โ†’ One (Aggregation)
    Multiple models feed a single reactive observer:
class Dashboard extends ReactiveModel {
  final List<Task> sources;
  Dashboard(this.sources) {
    for (final task in sources) addNested(task);
  }
}

final dashboard = Dashboard([task1, task2]);

ReactiveBuilder<Dashboard>(
  model: dashboard,
  builder: (_) => Text("Dashboard updated"),
);
- โœ” Any task change updates the dashboard automatically.


2-> Many โ†” Many (Shared Models)
    Same model instance used across multiple parents:
class Group extends ReactiveModel {
  final String name;
  final List<Task> tasks;

  Group({required this.name, required this.tasks}) {
    for (final task in tasks) addNested(task);
  }
}

- โœ” One task update reflects everywhere.
- โœ” No duplication or manual syncing required.


๐Ÿง  How It Works (High Level)
- Models extend ReactiveModel.
- Field setters call notifyListeners(fieldName) when the value changes.
- ReactiveBuilder widgets listen to either:
- Whole model (object-wise)
- Specific fields (field-wise)
- Nested models propagate changes upward automatically.
- Widgets rebuild safely, respecting Flutter lifecycle.


๐Ÿ›ฃ Roadmap
- Batch updates / transactions
- Async persistence hooks
- Database adapters
- DevTools / debug inspector
- Optional code generation


๐Ÿงช Status
- Version: 0.0.5
- Stability: Stable/No major updates are peding
- Use case: Learning, prototyping, early production experiments


๐Ÿ“Œ Summary
- reactive_orm is ideal when you want:
- Clean Dart models
- Minimal boilerplate
- ORM-like mental model
- Fine-grained UI reactivity
- No framework lock-in
1
likes
0
points
626
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight reactive ORM-style state management package for Flutter.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on reactive_orm