import 'package:flutter/material.dart';


class ConstrainedForm extends StatelessWidget {
  final GlobalKey<FormState> formKey;
  final List<Widget> children;
  final AutovalidateMode? autovalidateMode;
  
  const ConstrainedForm({
    super.key, 
    required this.formKey, 
    required this.children,
    this.autovalidateMode,
  });

  @override
  Widget build(BuildContext context) {
    return Center(
      child: SingleChildScrollView(
        padding: const EdgeInsets.all(16.0),
        child: ConstrainedBox(
          constraints: const BoxConstraints(maxWidth: 400),
          child: Form(
            key: formKey,
            autovalidateMode: autovalidateMode ?? AutovalidateMode.disabled,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: children,
            ),
          ),
        ),
      ),
    );
  }
}
