layrz_state 1.0.2 copy "layrz_state: ^1.0.2" to clipboard
layrz_state: ^1.0.2 copied to clipboard

A fork of vxstate with added features and improvements.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:layrz_state/layrz_state.dart';

class MyStore extends LayrzStore {
  int counter = 0;
}

class IncrementMutation extends StateMutation<MyStore> {
  @override
  void perform() => store.counter++;
}

void main() {
  runApp(
    LayrzState(
      store: MyStore(),
      child: const MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Layrz State Example')),
        body: Column(
          children: [
            Text("${LayrzState.of<MyStore>(context)}"),
            Center(
              child: StateBuilder<MyStore>(
                mutations: {IncrementMutation},
                builder: (context, store, status) {
                  return Text('Counter: ${store.counter}', style: const TextStyle(fontSize: 24));
                },
              ),
            ),
          ],
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () => IncrementMutation(),
          child: const Icon(Icons.add),
        ),
      ),
    );
  }
}
0
likes
160
points
358
downloads

Publisher

verified publishergoldenm.com

Weekly Downloads

A fork of vxstate with added features and improvements.

Repository (GitHub)
View/report issues

Topics

#state-management #layrz #vxstate

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on layrz_state