veto 0.0.1+1
veto: ^0.0.1+1 copied to clipboard
A lightweight MVVM state management solution originally inspired by the FilledStacks stacked package.
📚 Veto #
A lightweight MVVM state management solution originally inspired by the FilledStacks stacked package.

🛠 How to use it? #
- Create a view model.
import 'package:flutter/material.dart';
import 'package:veto/base_view_model.dart';
class VetoViewModel extends BaseViewModel<String> {
int counter = 0;
@override
Future<void> initialise({arguments}) async {
debugPrint('''[🐛] [DEBUG] [🌟] [VetoViewModel.initialise] [📞] I was initialised!''');
super.initialise();
}
@override
Future<void> dispose() async {
debugPrint('''[🐛] [DEBUG] [🌟] [VetoViewModel.dispose] [📞] I was disposed!''');
super.dispose();
}
void increment() {
counter++;
rebuild();
}
}
- Create a view with the view model.
import 'package:flutter/material.dart';
import 'package:veto/base_view_model.dart';
import 'veto_view_model.dart';
class VetoView extends StatelessWidget {
const VetoView({Key? key}) : super(key: key);
static const String route = 'veto-view';
@override
Widget build(BuildContext context) {
return ViewModelBuilder<VetoViewModel>(
argumentBuilder: () => 'Test',
builder: (context, model) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(model.counter.toString()),
ElevatedButton(
onPressed: model.increment,
child: const Text('Increment'),
),
],
),
),
);
},
viewModelBuilder: () => VetoViewModel(),
);
}
}
- Enjoy MVVM! 😍
The entire package has extensive documentation. Reading the BaseViewModel class from top to bottom will give you a good idea of the benefits of this package. Also, a good example project is next on the list to create and while doing that I will also update this readme with a lot more examples of the package functionality. For now I hope the package documentation will suffice. If you have any questions feel free to contact me through codaveto.com.