smart_forms 1.2.0 smart_forms: ^1.2.0 copied to clipboard
A flutter forms generator based on objects with multiple parameters.
import 'package:flutter/material.dart';
import 'package:smart_forms/models/field.model.dart';
import 'package:smart_forms/models/form.model.dart';
import 'package:smart_forms/smart_forms.dart';
import 'package:smart_forms/utils/enums.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Smart Forms',
theme: ThemeData(
primarySwatch: Colors.black,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Smart Forms'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
FormModel _form;
_formDone(Map<String, dynamic> res) {
print(res);
}
@override
void initState() {
_form = FormModel(
submitButton: "Submit",
resetButton: "Restart",
name: "Test",
fields: [
FieldModel(
label: "Field 1",
type: Types.number,
vallidate: true,
),
FieldModel(
label: "Field 2",
type: Types.text,
vallidate: true,
)
]);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: SmartForms(
form: _form,
callback: _formDone,
),
),
);
}
}