textFormField method

String textFormField(
  1. String elementName,
  2. String elementType,
  3. Map<String, dynamic> map, {
  4. String? parent,
})

Implementation

String textFormField(String elementName, String elementType, Map<String, dynamic> map, {String? parent}) {
  final initialValue = map['initialValue'] ?? '';
  final autovalidateMode = map['autovalidateMode'] ?? 'AutovalidateMode.onUserInteraction';
  if (!map.containsKey('inputDecoration')) {
    map['inputDecoration'] = {};
  }
  return '''
 SizedBox(
   height: 60,
   child:
 TextFormField(
      autocorrect: ${map['autocorrect'] ?? true},
      autofillHints: ${map['autofillHints'] ?? null},
      autofocus: ${map['autoFocus'] ?? true},
      autovalidateMode: $autovalidateMode,
      buildCounter: ${map['buildCounter'] ?? null},
      ${map['cursorColor'] != null ? 'cursorColor: ${map['cursorColor']},' : ''}
      ${map['cursorHeight'] != null ? 'cursorHeight: ${map['cursorHeight']},' : ''}
      ${map['cursorRadius'] != null ? 'cursorRadius: ${map['cursorRadius']},' : ''}
      ${map['cursorWidth'] != null ? 'cursorWidth: ${map['cursorWidth']},' : ''}
      decoration: const InputDecoration(
        labelText: '${map['label'] ?? map['inputDecoration']?['labelText'] ?? elementName[0].toUpperCase() + elementName.substring(1)}',
        labelStyle: ${map['inputDecoration']?['labelStyle'] ?? 'TextStyle(fontSize: 16.0, color: Colors.black)'},
        floatingLabelBehavior: ${map['inputDecoration']?['floatingLabelBehavior'] ?? 'FloatingLabelBehavior.auto'},
        hintText: '${map['inputDecoration']?['hintText'] ?? ''}',
        helperText: '${map['inputDecoration']?['helperText'] ?? ''}',
        fillColor: ${map['inputDecoration']?['fillColor'] ?? 'Colors.white'},
        hoverColor: ${map['inputDecoration']?['hoverColor'] ?? 'Color.fromARGB(255, 161, 179, 239)'},
        filled:${map['inputDecoration']?['filled'] ?? 'true'},
        errorMaxLines: ${map['inputDecoration']?['errorMaxLines'] ?? '1'},
        errorStyle: ${map['inputDecoration']?['errorStyle'] ?? 'TextStyle( color: Colors.red, fontSize: 12.0 )'},
        border: ${map['inputDecoration']?['border'] ?? 'InputBorder.none'},
        enabledBorder: ${map['inputDecoration']?['enabledBorder'] ?? 'OutlineInputBorder(borderSide: BorderSide(color: Colors.white, width: 1.0))'},
        focusedBorder: ${map['inputDecoration']?['focusedBorder'] ?? 'OutlineInputBorder(borderSide: BorderSide(color: Colors.blue, width: 1.0))'},
        disabledBorder: ${map['inputDecoration']?['disabledBorder'] ?? 'OutlineInputBorder(borderSide: BorderSide(color: Colors.grey))'},
        enabled: ${map['inputDecoration']?['enabled'] ?? 'true'},
        prefixIcon: ${map['inputDecoration']?['prefixIcon'] ?? 'null'},
        prefixText: ${map['inputDecoration']?['prefixText'] ?? 'null'},
        suffixIcon: ${map['inputDecoration']?['suffixIcon'] ?? 'null'},
        suffixText: ${map['inputDecoration']?['suffixText'] ?? 'null'},
        prefix: ${map['inputDecoration']?['prefix'] ?? 'null'},
        suffix: ${map['inputDecoration']?['suffix'] ?? 'null'},
        counterText: ${map['inputDecoration']?['counterText'] ?? 'null'},
        counterStyle: ${map['inputDecoration']?['counterStyle'] ?? 'null'},
        contentPadding: ${map['inputDecoration']?['contentPadding'] ?? 'EdgeInsets.all(5.0)'},
        isDense: ${map['inputDecoration']?['isDense'] ?? 'true'},
        alignLabelWithHint: ${map['inputDecoration']?['alignLabelWithHint'] ?? 'false'},
      ),
      enabled: ${map['enabled'] ?? 'true'},
      enableIMEPersonalizedLearning: ${map['enableIMEPersonalizedLearning'] ?? 'false'},
      enableInteractiveSelection: ${map['enableInteractiveSelection'] ?? 'true'},
      enableSuggestions: ${map['enableSuggestions'] ?? 'true'},
      expands: ${map['expands'] ?? 'true'},
      focusNode: ${map['focusNode'] ?? 'null'},
      initialValue: ${parent == null ? "_formData['$elementName'] ?? '$initialValue'" : "_formData['$parent']?['$elementName'] ?? '$initialValue'"},
      inputFormatters: ${map['inputFormatters'] ?? 'null'},
      keyboardAppearance: ${map['keyboardAppearance'] ?? 'Brightness.light'},
      keyboardType: ${keyboardType((map['keyboardType'] ?? map['type'] ?? 'none').toString())},
      maxLength: ${map['maxLength'] ?? 'null'},
      maxLengthEnforcement: ${map['maxLengthEnforcement'] ?? 'null'},
      maxLines: ${map['maxLines'] ?? 'null'},
      minLines: ${map['minLines'] ?? 'null'},
      mouseCursor: ${map['mouseCursor'] ?? 'null'},
      obscureText: ${map['obscureText'] ?? 'false'},
      obscuringCharacter: ${map['obscuringCharacter'] ?? '"•"'},
      onChanged:(value) => onSaved('${elementName}', value, parent: '${parent ?? ''}'),
      onSaved: (value) => onSaved('${elementName}', value, parent: '${parent ?? ''}'),
      scrollPadding: const EdgeInsets.all(5.0),
      ${buildValidator(map['validators'] as List?)}
    ), // TextFormField
  ) // SizedBox
  ''';
}