statyx 0.0.6 copy "statyx: ^0.0.6" to clipboard
statyx: ^0.0.6 copied to clipboard

State management with MVVM pattern

State management for Flutter.

Motivation #

Most of the time, I don't need all the features in GetX. Based on my experience, I extracted these frequently used functions and made some changes.

Features #

  • All Rx types from GetX(RxInt, RxList..)
  • Obx from GetX
  • ViewModel that observes Widget life circle (onInit, onReady, onClose)

Usage #

//ViewModel
class HomeViewModel extends ViewModel {
  final counter = 0.obs;

  @override
  void onInit() {} // called in initState()

  @override
  void onClose() {} // called in dispose()
}

//View
class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Vmx(
      create: () => HomeViewModel(),
      builder: (vm) => Scaffold(
        appBar: AppBar(title: const Text('Hello StatyX')),
        floatingActionButton: FloatingActionButton(
          onPressed: () => vm.counter.value++,
          child: const Icon(Icons.add),
        ),
        body: Center(child: Obx(() => Text('${vm.counter.value}'))),
      ),
    );
  }
}




1
likes
0
pub points
54%
popularity

Publisher

unverified uploader

State management with MVVM pattern

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on statyx