keeper 0.0.1 copy "keeper: ^0.0.1" to clipboard
keeper: ^0.0.1 copied to clipboard

Simple and flexible state storage mediator for Flutter applications.

example/README.md

Example #

These are simple examples of a Counter class. They show how to use the plugin with the synchronous and asynchronous keys.

Counter (counter.dart) #

The example of a counter using sync keys.

import 'package:keeper/keeper.dart';

part 'counter.g.dart';

class Counter = _Counter with _$CounterKeeper;

KeepKey counterValue() => MemoryKeep().key('counter_value');

@kept
class _Counter {
  @At(counterValue)
  int value = 0;

  void increment() {
    value++;
  }
}

Counter Async (counter_async.dart) #

The example of a counter using async keys.

import 'package:keeper/keeper.dart';

part 'counter_async.g.dart';

class CounterAsync = _CounterAsync with _$CounterAsyncKeeper;

KeepAsyncKey<int> counterAsyncValue() => MemoryKeep().asyncKey('counter_async');

@kept
class _CounterAsync {
  @AtAsync(counterAsyncValue)
  KeepAsyncValue<int> value = KeepAsyncValue(0);

  Future increment() async {
    await value.set(await value.get() + 1);
  }
}
1
likes
130
pub points
0%
popularity

Publisher

verified publisherandrebaltazar.com

Simple and flexible state storage mediator for Flutter applications.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on keeper