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

State management with MVVM pattern

State management for Flutter, drawn out from GetX.

Features #

  • All Rx types from GetX(RxInt, RxList..)
  • Obx from GetX
  • ViewModel that observe life circle event

Getting started #

GetX State Management

Usage #

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

  @override
  void onInit() {}

  @override
  void onClose() {}
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends VMState<HomePage, HomeViewModel> {
  @override
  HomeViewModel createViewModel() => HomeViewModel();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Hello StatyX')),
      floatingActionButton: FloatingActionButton(
        onPressed: () => viewModel.counter.value++,
        child: const Icon(Icons.add),
      ),
      body: Center(
        child: Obx(
              () => Text(
            '${viewModel.counter.value}',
            style: Theme.of(context).textTheme.headlineMedium,
          ),
        ),
      ),
    );
  }
}



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