{"id":21372277,"url":"https://github.com/rxlabz/flutter_formgen_poc","last_synced_at":"2026-05-03T15:35:54.697Z","repository":{"id":66351583,"uuid":"193500434","full_name":"rxlabz/flutter_formgen_poc","owner":"rxlabz","description":"a Flutter code generation sandbox","archived":false,"fork":false,"pushed_at":"2019-06-24T13:42:15.000Z","size":69,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-18T23:25:57.969Z","etag":null,"topics":["code-generation","dartlang","flutter"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rxlabz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-24T12:24:45.000Z","updated_at":"2020-03-23T23:34:15.000Z","dependencies_parsed_at":"2023-02-24T18:00:54.555Z","dependency_job_id":null,"html_url":"https://github.com/rxlabz/flutter_formgen_poc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rxlabz/flutter_formgen_poc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxlabz%2Fflutter_formgen_poc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxlabz%2Fflutter_formgen_poc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxlabz%2Fflutter_formgen_poc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxlabz%2Fflutter_formgen_poc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxlabz","download_url":"https://codeload.github.com/rxlabz/flutter_formgen_poc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxlabz%2Fflutter_formgen_poc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32575113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generation","dartlang","flutter"],"created_at":"2024-11-22T08:18:51.048Z","updated_at":"2026-05-03T15:35:54.670Z","avatar_url":"https://github.com/rxlabz.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flutter form generation POC\n\nA little code generation experimentation : Define a FormModel, and generate a FormWidget\n\nFor example, this model : \n\n```dart\n@RXForm()\nclass UserFormModel extends ValueNotifier\u003cMap\u003cString, String\u003e\u003e {\n  @required\n  String email;\n  String emailValidator(String value) =\u003e\n      validateMail(value) ?? validateRequired(value);\n\n  String firstname;\n\n  String lastname;\n\n  @required\n  @obscure\n  String password;\n  String passwordValidator(String value) =\u003e validateRequired(value);\n\n  @override\n  Map\u003cString, String\u003e get value =\u003e {\n        'email': email,\n        'lastname': lastname,\n        'firstname': firstname,\n        'password': password,\n      };\n  @override\n  set value(_) {}\n\n  UserFormModel({this.email, this.password}) : super(null);\n\n  onSubmit() =\u003e notifyListeners();\n}\n```\n\nwill generate\n\n```dart\n// GENERATED CODE - DO NOT MODIFY BY HAND\n\npart of 'user_form_model.dart';\n\n// **************************************************************************\n// FormGenerator\n// **************************************************************************\n\nclass UserForm extends StatefulWidget {\n  UserForm(this.model);\n\n  final UserFormModel model;\n\n  @override\n  _UserFormState createState() =\u003e _UserFormState();\n}\n\nclass _UserFormState extends State\u003cUserForm\u003e {\n  final GlobalKey\u003cFormState\u003e _formKey = GlobalKey\u003cFormState\u003e();\n\n  TextEditingController emailController;\n\n  TextEditingController firstnameController;\n\n  TextEditingController lastnameController;\n\n  TextEditingController passwordController;\n\n  bool _autovalidate = false;\n\n  @override\n  void initState() {\n    emailController = TextEditingController();\n    firstnameController = TextEditingController();\n    lastnameController = TextEditingController();\n    passwordController = TextEditingController();\n    super.initState();\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return Form(\n        key: _formKey,\n        child: ListView(children: [\n          TextFormField(\n              key: Key('emailField'),\n              controller: emailController,\n              decoration: InputDecoration(labelText: 'Email'),\n              validator: widget.model.emailValidator,\n              onSaved: (value) =\u003e widget.model.email = value,\n              autovalidate: _autovalidate),\n          TextFormField(\n              key: Key('firstnameField'),\n              controller: firstnameController,\n              decoration: InputDecoration(labelText: 'Firstname'),\n              onSaved: (value) =\u003e widget.model.firstname = value),\n          TextFormField(\n              key: Key('lastnameField'),\n              controller: lastnameController,\n              decoration: InputDecoration(labelText: 'Lastname'),\n              onSaved: (value) =\u003e widget.model.lastname = value),\n          TextFormField(\n              key: Key('passwordField'),\n              controller: passwordController,\n              obscureText: true,\n              decoration: InputDecoration(labelText: 'Password'),\n              validator: widget.model.passwordValidator,\n              onSaved: (value) =\u003e widget.model.password = value,\n              autovalidate: _autovalidate),\n          RaisedButton(\n              child: Text('Submit'),\n              onPressed: () {\n                if (_formKey.currentState.validate()) {\n                  _formKey.currentState.save();\n                  widget.model.onSubmit();\n                } else\n                  setState(() =\u003e _autovalidate = true);\n              })\n        ]));\n  }\n}\n```\n\nand could be used this way : \n\n```dart\nclass UserFormScreen extends StatefulWidget {\n  @override\n  _UserFormScreenState createState() =\u003e _UserFormScreenState();\n}\n\nclass _UserFormScreenState extends State\u003cUserFormScreen\u003e {\n  final UserFormModel formModel = UserFormModel();\n\n  @override\n  void initState() {\n    formModel.addListener(() =\u003e print('submitted values ${formModel.value}'));\n    super.initState();\n  }\n\n  @override\n  void dispose() {\n    formModel.dispose();\n    super.dispose();\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(),\n      body: Padding(\n        padding: const EdgeInsets.all(16.0),\n        child: UserForm(formModel),\n      ),\n    );\n  }\n}\n```\n\n## Resources\n\n- [BoringShow](https://www.youtube.com/watch?v=mYDFOdl-aWM)\n- [Code generation in Dart : the basics](https://medium.com/flutter-community/part-1-code-generation-in-dart-the-basics-3127f4c842cc)\n- [Code generation in Dart : source_gen \u0026 build_runner](https://medium.com/flutter-community/part-2-code-generation-in-dart-annotations-source-gen-and-build-runner-bbceee28697b)\n\n- source code generation lib : [code_builder](https://pub.dartlang.org/packages/code_builder)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxlabz%2Fflutter_formgen_poc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxlabz%2Fflutter_formgen_poc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxlabz%2Fflutter_formgen_poc/lists"}