Implementation
@override
Widget? attach(BuildContext context, T controller) {
final theme = Theme.of(context);
final themeStyle = theme.textTheme.bodyLarge ?? const TextStyle();
final primaryColor = controller.primary;
final secondaryColor = controller.secondaryColor ?? const Color(0xffbbbbbb);
var style = (controller.textStyle ?? themeStyle).copyWith(
fontSize: controller.textSize ?? 18,
height: 1.2,
);
var hintStyle = (controller.hintStyle ?? themeStyle).copyWith(
fontSize: controller.textSize ?? 18,
height: 1.2,
color: controller.text.isNotEmpty
? Colors.transparent
: controller.hintTextColor ?? secondaryColor,
);
final colors = ValueState(
primary: secondaryColor,
secondary: primaryColor,
disable: secondaryColor,
);
final defaultColor = colors.fromController(controller);
return GestureDetector(
onTap: () => controller.showKeyboard(context),
child: Container(
color: Colors.transparent,
padding: controller.padding,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
textDirection: controller.textDirection,
children: [
if (drawableStartBuilder != null)
drawableStartBuilder!(context, controller)
else
IconView(
visibility: controller.drawableStart != null,
icon: controller.drawableStart,
size: controller.drawableStartSize,
tint: controller.drawableStartTint ?? defaultColor,
marginCustom: controller.drawableStartSpace,
),
Expanded(
child: TextField(
canRequestFocus: true,
enabled: controller.enabled,
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.zero,
isDense: true,
isCollapsed: true,
hintText: controller.hintText,
hintStyle: hintStyle,
hintTextDirection: controller.textDirection,
),
autocorrect: controller.autocorrect,
autofillHints: controller.autofillHints,
autofocus: controller.autoFocus,
clipBehavior: controller.clipBehaviorText,
controller: controller._editor,
cursorColor: controller.cursorColor ?? primaryColor,
cursorHeight: controller.cursorHeight,
cursorOpacityAnimates: controller.cursorOpacityAnimates,
cursorRadius: controller.cursorRadius,
cursorWidth: controller.cursorWidth,
contentInsertionConfiguration:
controller.contentInsertionConfiguration,
contextMenuBuilder: controller.contextMenuBuilder,
dragStartBehavior: controller.dragStartBehavior,
enableIMEPersonalizedLearning:
controller.enableIMEPersonalizedLearning,
enableInteractiveSelection:
controller.enableInteractiveSelection,
enableSuggestions: controller.enableSuggestions,
expands: controller.expands,
focusNode: controller._node,
inputFormatters: controller._formatter,
keyboardAppearance: controller.keyboardAppearance,
keyboardType: controller.inputType,
maxLines: controller.maxLines,
magnifierConfiguration: controller.magnifierConfiguration,
maxLength: null,
minLines: controller.minLines,
mouseCursor: controller.mouseCursor,
obscureText: controller.obscureText,
obscuringCharacter: controller.obscuringCharacter,
onAppPrivateCommand: controller.onAppPrivateCommand,
onChanged: controller._handleEditingChange,
onEditingComplete: controller.onEditingComplete,
onSubmitted: controller.onSubmitted,
onTapOutside: controller.onTapOutside,
readOnly: controller.isReadMode,
restorationId: controller.restorationId,
scribbleEnabled: controller.scribbleEnabled,
scrollController: controller.scrollControllerText,
scrollPadding: controller.textScrollPadding,
scrollPhysics: controller.textScrollPhysics,
selectionControls: controller.selectionControls,
selectionHeightStyle: controller.selectionHeightStyle,
selectionWidthStyle: controller.selectionWidthStyle,
showCursor: controller.showCursor,
smartDashesType: controller.smartDashesType,
smartQuotesType: controller.smartQuotesType,
spellCheckConfiguration: controller.spellCheckConfiguration,
strutStyle: controller.strutStyle,
style: style,
textAlign: controller.textAlign ?? TextAlign.start,
textCapitalization: controller.textCapitalization,
textDirection: controller.textDirection,
textInputAction: controller.textInputAction,
undoController: controller.undoController,
),
),
if (controller.isIndicatorVisible)
Container(
width: controller.indicatorSize,
height: controller.indicatorSize,
padding: EdgeInsets.all(controller.indicatorSize * 0.05),
margin: controller.drawableEndSpace,
child: CircularProgressIndicator(
strokeWidth: controller.indicatorStroke,
color: controller.indicatorStrokeColor ?? defaultColor,
backgroundColor: controller.indicatorStrokeBackground ??
defaultColor?.withOpacity(0.1),
),
)
else if (drawableEndBuilder != null)
drawableEndBuilder!(context, controller)
else
IconView(
visibility: controller.drawableEnd != null,
icon: controller.drawableEnd,
size: controller.drawableEndSize,
tint: controller.drawableEndTint ?? defaultColor,
marginCustom: controller.drawableEndSpace,
onToggleClick:
controller.drawableEndAsEye ? controller.onChangeEye : null,
),
],
),
),
);
}