import 'package:flutter/material.dart'; class FormWrapper extends StatefulWidget { final List? fields; final List? buttons; final GlobalKey? formState; const FormWrapper({Key? key, this.formState, this.fields, this.buttons}) : super(key: key); @override _FormWrapperState createState() => _FormWrapperState(); } class _FormWrapperState extends State { @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(10.0), child: Form( key: widget.formState, child: Column( children: [ Column( children: widget.fields ?.map((e) => Padding( padding: const EdgeInsets.symmetric(vertical: 5.0), child: e)) .toList() ?? [], ), Container( padding: const EdgeInsets.only(top: 10.0), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: widget.buttons ?? [], ), ), ], ), ), ); } }