forked from eatvio/eatvio_app
refactor(diary): Refactoring again
This commit is contained in:
@@ -92,61 +92,60 @@ class CustomTextFormField extends StatelessWidget {
|
||||
return alignment != null
|
||||
? Align(
|
||||
alignment: alignment ?? Alignment.center,
|
||||
child: textFormFieldWidget,
|
||||
child: _buildTextFormFieldWidget(context),
|
||||
)
|
||||
: textFormFieldWidget;
|
||||
: _buildTextFormFieldWidget(context);
|
||||
}
|
||||
|
||||
Widget get textFormFieldWidget => SizedBox(
|
||||
width: width ?? double.maxFinite,
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode ?? FocusNode(),
|
||||
autofocus: autofocus!,
|
||||
style: textStyle ?? theme.textTheme.titleMedium,
|
||||
obscureText: obscureText!,
|
||||
textInputAction: textInputAction,
|
||||
maxLines: maxLines ?? 1,
|
||||
decoration: decoration,
|
||||
validator: validator,
|
||||
keyboardType: keyboardType,
|
||||
onSaved: onSaved,
|
||||
onChanged: onChanged,
|
||||
inputFormatters: inputFormatters,
|
||||
initialValue: initialValue,
|
||||
),
|
||||
);
|
||||
InputDecoration get decoration => InputDecoration(
|
||||
hintText: hintText ?? "",
|
||||
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,
|
||||
prefixIcon: prefix,
|
||||
prefixIconConstraints: prefixConstraints,
|
||||
suffixIcon: suffix,
|
||||
suffixIconConstraints: suffixConstraints,
|
||||
isDense: true,
|
||||
contentPadding: contentPadding ?? EdgeInsets.all(6.h),
|
||||
fillColor: fillColor ?? theme.colorScheme.onPrimary,
|
||||
filled: filled,
|
||||
border: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||
),
|
||||
enabledBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
focusedBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
_buildTextFormFieldWidget(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: width ?? double.maxFinite,
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode ?? FocusNode(),
|
||||
autofocus: autofocus!,
|
||||
style: textStyle ?? Theme.of(context).textTheme.titleMedium,
|
||||
obscureText: obscureText!,
|
||||
textInputAction: textInputAction,
|
||||
maxLines: maxLines ?? 1,
|
||||
decoration: _buildInputDecoration(context),
|
||||
validator: validator,
|
||||
keyboardType: keyboardType,
|
||||
onSaved: onSaved,
|
||||
onChanged: onChanged,
|
||||
inputFormatters: inputFormatters,
|
||||
initialValue: initialValue,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
InputDecoration _buildInputDecoration(BuildContext context) {
|
||||
return InputDecoration(
|
||||
hintText: hintText ?? "",
|
||||
hintStyle: hintStyle ?? Theme.of(context).textTheme.bodyLarge,
|
||||
prefixIcon: prefix,
|
||||
prefixIconConstraints: prefixConstraints,
|
||||
suffixIcon: suffix,
|
||||
suffixIconConstraints: suffixConstraints,
|
||||
isDense: true,
|
||||
contentPadding: contentPadding ?? EdgeInsets.all(6),
|
||||
fillColor: fillColor ?? Theme.of(context).colorScheme.onPrimary,
|
||||
filled: filled,
|
||||
border: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||
),
|
||||
enabledBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||
),
|
||||
focusedBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user