formify 1.0.0 formify: ^1.0.0 copied to clipboard
With Formify, you can quickly and easily create forms with customizable widget and strong validation.
import 'package:example/form_demo.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: 'Formify Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final formDemo = FormDemo();
@override
void initState() {
super.initState();
formDemo.setInitialValues({
'username': 'thisismyusername',
'password': 'password',
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Formify Demo'),
),
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: Column(
children: [
...formDemo.getWidgets(),
FilledButton(
onPressed: () {
if (formDemo.isFormValid()) {
//DO SOMETHING
}
},
child: const Text('Login'),
),
],
),
),
);
}
}