property_ui_generator

Creator: coderz1093

Last updated:

0 purchases

property_ui_generator Image
property_ui_generator Images
Add to Cart

Description:

property ui generator

Generator for property_ui_annotation
This is useful when you need to arrange a large number of widgets, such as in a configuration screen, and you want each value to be synchronized with the class.
This package generates code that inspects the fields marked with annotations and places the appropriate editing widgets.
For example, a TextField will be generated for a String type, and a Switch for a bool type.
Below is the source code and the corresponding actual widget placement example.
import 'package:property_ui_annotation/property_ui_annotation.dart';

class Example {
@Property(readonly: true, hintText: "enter your name.")
String name;
@Property()
double height;
@Property()
int age;
@Property()
bool die;
@Property(debug: true)
bool debugParameter;

Example() {
this.name = "user";
this.height = 180;
this.age = 20;
this.die = false;
this.debugParameter = false;
}
}
copied to clipboard

The code to place this widget itself looks like this
Although it is not excerpted here, the classes ExampleUI and ExampleUIState are actually generated.
class _MyHomePageState extends State<MyHomePage> {
Example _example;

@override
void initState() {
super.initState();
this._example = Example();
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(children: [ExampleUI(_example), Spacer()]),
),
);
}
}
copied to clipboard
example project is here.
Usage #
Add packages to your pubspec.yaml.
dependencies:
property_ui_annotation: ^1.0.1

dev_dependencies:
build_runner: ^1.10.11
property_ui_generator: ^1.0.4
copied to clipboard
Add @Property annotation to your class.
import 'package:property_ui_annotation/property_ui_annotation.dart';

class Example {
@Property(readonly: true, hintText: "enter your name.")
String name;
@Property()
double height;
@Property()
int age;
@Property()
bool die;
@Property(debug: true)
bool debugParameter;

Example() {
this.name = "user";
this.height = 180;
this.age = 20;
this.die = false;
this.debugParameter = false;
}
}
copied to clipboard
Run build_runner on your project.
flutter packages pub run build_runner build
copied to clipboard
Supported data types #

String
int
double
bool

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.