livedatax 1.0.0 copy "livedatax: ^1.0.0" to clipboard
livedatax: ^1.0.0 copied to clipboard

LiveDataX is a Dart package that brings the original LiveData, MutableLiveData and ViewModel classes from native Android code to Dart. It helps implement the MVVM pattern in Dart applications, followi [...]

example/livedatax_example.dart

import 'viewModel/example_view_model.dart';

void main() async {
  //create view model
  ExampleViewModel viewModel = ExampleViewModel(null);

  //observe data
  observer(value) {
    print('value: $value');
  }
  viewModel.liveData.observe(observer);

  //fetch data
  viewModel.getIntData();

  //simulation of network call with delay of 2 seconds
  await Future.delayed(Duration(seconds: 2));

  //remove observers
  viewModel.liveData.removeObserver(observer);
  //or, simply dispose
  viewModel.dispose();
}
copied to clipboard
1
likes
130
points
27
downloads

Publisher

verified publisher3p-cups.com

Weekly Downloads

2024.09.25 - 2025.04.09

LiveDataX is a Dart package that brings the original LiveData, MutableLiveData and ViewModel classes from native Android code to Dart. It helps implement the MVVM pattern in Dart applications, following Google's clean architecture principles.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on livedatax