buildTextWidget method
Widget
buildTextWidget(
- dynamic context,
- bool isFloatLabel
)
Implementation
Widget buildTextWidget(context, bool isFloatLabel) {
TextStyle? formLabelStyle;
// we need to look up to the form to know whether we should show
// the label here, as the Form may have already showed them (side by side)
bool shouldShowLabel = true;
ensemble.FormState? formState = EnsembleForm.of(context);
if (formState != null) {
shouldShowLabel = formState.widget.shouldFormFieldShowLabel;
// also see if the parent Form defined a labelStyle we can fall back to
formLabelStyle = formState.widget.labelStyle;
}
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (shouldShowLabel && controller.label != null && !isFloatLabel)
Container(
margin: const EdgeInsets.only(bottom: 8.0),
child: Text(
controller.label!,
// use our labelStyle and fallback to the parent Form's labelStyle
style: controller.labelStyle ??
formLabelStyle ??
Theme.of(context).inputDecorationTheme.labelStyle,
),
),
// semantics for whatever text input comes through
MergeSemantics(
child: Semantics(
label: controller.label,
child: widget,
),
),
if (shouldShowLabel && controller.description != null)
Container(
margin: const EdgeInsets.only(top: 12.0),
child: Text(controller.description!),
),
],
);
}