mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-08-06 06:46:05 +08:00
New Example - Stateless MObX Counter App (#104)
Co-authored-by: A HEAD FULL OF DREAMS <workdeveloper@gmail.com> Co-authored-by: Nishant Srivastava <nisrulz@users.noreply.github.com>
This commit is contained in:
18
statless_counter_app/lib/counter.dart
Normal file
18
statless_counter_app/lib/counter.dart
Normal file
@ -0,0 +1,18 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
// Include generated file
|
||||
part 'counter.g.dart';
|
||||
|
||||
// This is the class used by rest of your codebase
|
||||
class Counter = _Counter with _$Counter;
|
||||
|
||||
// The store-class
|
||||
abstract class _Counter with Store {
|
||||
@observable
|
||||
int value = 0;
|
||||
|
||||
@action
|
||||
void increment() {
|
||||
value++;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user