witt

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

witt

Witt #
Simple state management powered by ValueNotifier and InheritedWidget.
Getting started #
Installing package
flutter pub add witt
flutter pub get
copied to clipboard
Import it
import 'package:witt/witt.dart
copied to clipboard
Usage #
Basic usage #
class CounterProvider {
final counter = ValueNotifier(0);

void incrementCounter() {
counter.value++;
}
}

...
return WProvider(
create: (context) => CounterProvider(),
child: const MaterialApp(
title: "Example App",
home: HomePage(),
),
);

...

class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
final counterP = WProvider.of<CounterProvider>(context);
return Scaffold(
body: WListener(
notifier: counterP.counter,
builder: (context) {
final counter = counterP.counter.value;
return Text(counter.toString());
},
),
floationActionButton: FloationActionButton(
onPressed: counterP.incrementCounter,
child: const Icon(Icons.add),
),
);
}
}
copied to clipboard
Important note #
Widget will not be re-rendered if WListener return const widget.
WListener(
notifier: counterP.counter,
(context, value) => const _CounterText(),
);
...

// This widget will not be re-rendered.
class _CounterText extends StatelessWidget {
const _CounterText({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
final counterP = WProvider.of<CounterProvider>(context);
final counterValue = counterP.counter.value;

return Center(child: Text(counterValue.toString()));
}
}
copied to clipboard
Additional Information #
This library is currently on experimental status and not ready for production. The API may change slightly when more features are added, and some use-cases may not be as simple as they could be.
Contributing #
Contributions are welcomed!
Here is a curated list of how you can help:

Report bugs and scenarios that are difficult to implement
Report parts of the documentation that are unclear
Update the documentation / add examples
Implement new features by making a pull-request

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.