zeba_academy_smart_forms 1.0.0
zeba_academy_smart_forms: ^1.0.0 copied to clipboard
JSON-driven smart form engine with validation, multi-step support, custom widgets and auto serialization.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:zeba_academy_smart_forms/zeba_academy_smart_forms.dart';
void main() {
runApp(const SmartFormExample());
}
class SmartFormExample extends StatelessWidget {
const SmartFormExample({super.key});
@override
Widget build(BuildContext context) {
final fields = [
FormFieldModel(
name: "name",
label: "Full Name",
type: "text",
required: true,
),
FormFieldModel(
name: "email",
label: "Email Address",
type: "text",
),
FormFieldModel(
name: "course",
label: "Select Course",
type: "dropdown",
options: ["Flutter", "AI", "Data Science"],
),
];
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "Smart Forms Demo",
theme: ThemeData(
primarySwatch: Colors.indigo,
inputDecorationTheme: const InputDecorationTheme(
border: OutlineInputBorder(),
),
),
home: Scaffold(
appBar: AppBar(
title: const Text("Smart Forms Demo"),
centerTitle: true,
elevation: 0,
),
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xFFE8ECFF),
Color(0xFFF7F8FF),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Center(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(24),
child: Card(
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.dynamic_form,
size: 60,
color: Colors.indigo,
),
const SizedBox(height: 16),
const Text(
"Dynamic Smart Form",
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 6),
const Text(
"JSON-driven form builder for Flutter apps",
style: TextStyle(
color: Colors.grey,
),
),
const SizedBox(height: 24),
SmartFormWidget(
fields: fields,
onSubmit: (data) {
debugPrint(data.toString());
},
),
],
),
),
),
),
),
),
),
),
);
}
}