From 36221885ff9453bdae3e07d6ae28b7b29d790a11 Mon Sep 17 00:00:00 2001 From: Matthew Patrick <Matthew.535200018@stu.untar.ac.id> Date: Mon, 25 Apr 2022 20:42:59 +0700 Subject: [PATCH] register_form - Added register forms --- lib/components/register_form.dart | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/components/register_form.dart b/lib/components/register_form.dart index a9bde36..eed90f3 100644 --- a/lib/components/register_form.dart +++ b/lib/components/register_form.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; class Register_Form extends StatefulWidget { Register_Form({Key? key}) : super(key: key); @@ -8,6 +9,8 @@ class Register_Form extends StatefulWidget { State<Register_Form> createState() => _Register_FormState(); } +final _formKey = GlobalKey<FormBuilderState>(); + class _Register_FormState extends State<Register_Form> { @override Widget build(BuildContext context) { @@ -42,6 +45,20 @@ class _Register_FormState extends State<Register_Form> { ), ], ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 25), + child: FormBuilder( + key: _formKey, + child: Column( + children: [ + makeInput(label: "First Name"), + makeInput(label: "Last Name"), + makeInput(label: "Email Address"), + makeInput(label: "Password", obscureText: true) + ], + ), + ), + ), Padding( padding: const EdgeInsets.symmetric(horizontal: 35), child: Container( @@ -91,3 +108,43 @@ class _Register_FormState extends State<Register_Form> { ); } } + +Widget makeInput({label, obscureText = false}) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + label, + style: const TextStyle( + fontSize: 12, fontWeight: FontWeight.bold, color: Colors.white), + ), + const SizedBox( + height: 5, + ), + FormBuilderTextField( + initialValue: "", + name: label, + obscureText: obscureText, + style: const TextStyle(color: Colors.white), + decoration: const InputDecoration( + contentPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 10), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.red, + ), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Colors.white, + ), + ), + border: + OutlineInputBorder(borderSide: BorderSide(color: Colors.white)), + ), + ), + const SizedBox( + height: 10, + ) + ], + ); +}