powerflutter_code_generation 0.1.1 powerflutter_code_generation: ^0.1.1 copied to clipboard
Code Generation for Powerflutter for Models, Assets and more use as dev_dependency and add annotations to your code
powerflutter_code_generation #
Powerflutter Code Generation Library
Getting Started #
- Add
powerflutter_code_generation
to your dev_dependencies. - Run
flutter packages pub run build_runner watch
in the terminal of the project - Add Annotations to your code like
@powermodel
and thepart 'filename.g.dart';
to the top of the file
Annotations #
@powermodel
: Used on a private (start it with underscore _
) model class a public class will be generated that inherits the private class and overrides every field with a setter and getter needed for Powerflutter databinding.
@ModelName("test")
Used on a field of a @powermodel
class sets the Name used in serialization etc. for this field
Example #
In the Powerflutter Examples we use the following simple model class:
import 'package:powerflutter/powerflutter.dart';
part 'counter.g.dart';
@powermodel
class _CounterModel with PowerModel {
int counter = 0;
}
This will generate a CounterModel
Class that has the Getters and Setters needed for Poweflutter.