0

我有一个表单小部件,它将 Column 作为它的子元素。Column 小部件的原因是在新行中有一个又一个的用户名和密码字段 - 密码字段。此外,我需要在各个字段旁边有用户名和密码徽标,因此我决定使用包含 Icon 和 TextFormField 的 Row 小部件。然而,颤振给我带来了错误。有人可以帮忙吗?

Row(
        children: [
          
      Padding(
        padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 30),
        child: TextFormField(
        
        enabled: formFieldEditable,
        validator: emptyNullValidatorForFormField,
        
        decoration: InputDecoration(
         focusedBorder: _inputFormFieldOutlineInputBorder(
          borderSideWidth: ProjectSpecifics.signinScreenInputBorderWidth,
          borderSideColor: ProjectSpecifics.signInPageInputBorder,
        ),
        
        enabledBorder:_inputFormFieldOutlineInputBorder(
          borderSideWidth: ProjectSpecifics.signinScreenInputBorderWidth,
          borderSideColor: ProjectSpecifics.signInPageInputBorder,
        ),
        
          
        /*icon: Container(
          decoration: BoxDecoration(
            border: Border.all(
              color: const Color(0xFF5663FE),
              width: 2,
            ),
        
            borderRadius: BorderRadius.circular(5),
          ),
          child: const Icon(
            Icons.email,
            color: ProjectSpecifics.signInPageInputBorder,
          ),
        ),*/
        
        labelText: "EMAIL"),
        
        
                onChanged: (val) {
        emailVariableReference = val;
                },
        ),
      ),],
      ),
4

1 回答 1

1

TextFormFieldFlexible或小部件包裹Expanded

Column(
  mainAxisAlignment: MainAxisAlignment.start,
  mainAxisSize: MainAxisSize.min,
  children: [
    Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        Icon(Icons.radar),
        Expanded(child: TextFormField()),
      ],
    ),
    Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        Icon(Icons.abc),
        Flexible(child: TextFormField()),
      ],
    ),
  ],
),
于 2022-02-27T12:37:28.693 回答