fiona_dynamic_form 1.4.1
fiona_dynamic_form: ^1.4.1 copied to clipboard
Dynamic Form package project. To create forms dynamically. You will find some input implementation but then you will be able to create any input you need.
example/lib/main.dart
import 'package:example/example/form_employee.dart';
import 'package:example/example/model/employee.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Dynamic Form Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Dynamic Form Example Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
FormEmployee form = FormEmployee();
void _buildAndShowEmployee() {
if( form.validate() ){
Employee emp = form.getEmployee();
print("Name: ${emp.name}" );
print("Password: ${emp.password}" );
print("Remember Me: ${emp.rememberMe}" );
print("City: ${emp.city}" );
print("Province: ${emp.province}" );
print("Country: ${emp.country}" );
print("Uuid: ${emp.id}" );
}else{
print("invalid");
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: form.draw(context)
),
floatingActionButton: FloatingActionButton(
onPressed: _buildAndShowEmployee,
tooltip: 'Submit',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}