import 'package:flutter/material.dart';

class VFormCell extends StatelessWidget {
  final String label;
  final Widget child;
  final double? labelWidth;
  final bool isExpanded;

  const VFormCell({
    super.key,
    required this.label,
    required this.child,
    this.labelWidth,
    this.isExpanded = true,
  });

  @override
  Widget build(BuildContext context) {
    final body = Row(
      mainAxisSize: isExpanded ? MainAxisSize.max : MainAxisSize.min,
      children: [
        SizedBox(
          width: labelWidth ?? 100,
          child: Text(
            label,
            style: const TextStyle(color: Colors.black, fontSize: 16),
          ),
        ),
        const SizedBox(width: 4),
        child,
      ],
    );
    if (!isExpanded) return body;

    return Expanded(
      child: body,
    );
  }
}
