Skip to main content

dynamic_form_builder1 0.0.3 copy "dynamic_form_builder1: ^0.0.3" to clipboard
dynamic_form_builder1: ^0.0.3 copied to clipboard

A reusable dynamic TextFormField builder package.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:dynamic_form_builder1/dynamic_form_builder1.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const FormExample(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class FormExample extends StatefulWidget {
  const FormExample({super.key});

  @override
  State<FormExample> createState() => _FormExampleState();
}

class _FormExampleState extends State<FormExample> {
  final _formKey = GlobalKey<FormState>();
  final TextEditingController nameController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Dynamic Form Builder')),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Form(
          key: _formKey,
          child: Column(
            children: [
              DynamicTextFormField(
                config: TextFieldConfig(
                  name: 'name',
                  label: 'Full Name',
                  hint: 'Enter your name',
                  required: true,
                ),
                controller: nameController,
              ),

              const SizedBox(height: 20),

              ElevatedButton(
                onPressed: () {
                  if (_formKey.currentState!.validate()) {
                    ScaffoldMessenger.of(context).showSnackBar(
                      SnackBar(content: Text(nameController.text)),
                    );
                  }
                },
                child: const Text('Submit'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
120
points
53
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A reusable dynamic TextFormField builder package.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on dynamic_form_builder1