0

我在 Flutter App 中为我的文本输入小部件创建了 InputDecorationTheme 主题。现在我想使用具有某些功能的 onTap() 方法添加后缀图标。如何在不编辑从为整个应用程序声明的主题中获取颜色、边框等的装饰的情况下将 suffixIcon 添加到 TextFormField。

我的输入装饰主题

inputDecorationTheme: InputDecorationTheme(
  filled: true,
  errorMaxLines: 1,
  errorStyle: TextStyle(
      height: 0
  ),
  border: OutlineInputBorder(
    borderRadius: BorderRadius.circular(3),
    borderSide: BorderSide(
        color: light_textFieldFillColor,
        style: BorderStyle.solid,
        width: 1),
  ),
  focusedBorder: OutlineInputBorder(
    borderRadius: BorderRadius.circular(3),
    borderSide: BorderSide(
        color: dark_primaryColor,
        style: BorderStyle.solid,
        width: 1),
  ),
  errorBorder: OutlineInputBorder(
    borderRadius: BorderRadius.circular(3),
    borderSide: BorderSide(
        color: dark_errorColor,
        style: BorderStyle.solid,
        width: 2),
  ),
  focusedErrorBorder: OutlineInputBorder(
    borderRadius: BorderRadius.circular(3),
    borderSide: BorderSide(
        color: dark_errorColor,
        style: BorderStyle.solid,
        width: 2),
  ),
  fillColor: dark_textFieldFillColor,
),

我的文本表单域

TextFormField(
  key: _key_form,
  controller: controller,
  inputFormatters:formatter,
  validator: validator,
  autovalidateMode: AutovalidateMode.onUserInteraction,
  autofocus: true,
  obscureText: ((this._isHidden != null) ? this._isHidden : false),
  focusNode: focus,
  keyboardType: keyboardType,
  enabled: true,
  textInputAction: TextInputAction.next,
  onFieldSubmitted: (value) {
    focus.unfocus();
    FocusScope.of(context).requestFocus(next);
  },
  // style: TextStyle(
  //     color: Constants.primaryTextColor,
  //     textBaseline: TextBaseline.alphabetic
  // ),
  maxLines: 1,
)
4

0 回答 0