full_context 0.5.1 full_context: ^0.5.1 copied to clipboard
Intuitive state management via Context. With FullContext you still need Providers and Builders to instantiate and display states, but management can all be done through Context
This package was made to facilitate State manipulation. Basically, you just need to add the State Type to the context to manipulate it via the context itself.
Features #
- You can create a Type provider via the FullContext Widget;
- In FullContext's children you can manipulate States through their Type in the Context.
Getting started #
Add type provider and create a type:
Widget build(BuildContext context) => FullContext(
onInit: (context) => context.set<int>(1),
builder: (context) => YourWidget(),
);
Usage #
When you have a FullContext as a parent directly or indirectly with the Type you want to use started:
Widget build(BuildContext context) => InkWell(
onTap: () => context.emit<int>(context.get<int>() + 1),
child: FCBuilder<int>((context, snapshot) =>
snapshot.hasData
? Text(snapshot.data!)
: const CircularProgressIndicator(),
)
);
Besides context.set<S>(state)
, context.emit<S>(state)
and context.get<S>()
, we have:
context.get$<S>()
which returnsValueStream<S>
;context.init<S>()
starts typeS
without initial state. Remember thatcontext.get<S>()
only works after the firstcontext.emit<S>(state)
;context.emitError<S, E>(E error, [StackTracer? stackTracer])
;context.close<S>()
ClosesS
stream.
Additional information #
Olá, me chamo Lucas, o criador deste pacote. Sou brasileiro e pretendo adicionar Factories nesse projeto após, é claro, tornar o que já tem hoje mais sucinto.
Metas para o futuro #
- Adicionar Factories;
- Criar testes automatizados;
- Criar um exemplo decente.
Tenho em mente tornar esse projeto igual o Services do ASP.NET CORE, com a única diferença de criar na mão as instâncias com o context.