文本字段和下拉菜单在行中应具有相同的高度

问题描述 投票:0回答:1

我尝试使两者高度相等,但它仅适用于一台设备,但对于差异设备,它会发生变化

IntrinsicHeight(
  child: Row(
    crossAxisAlignment: CrossAxisAlignment.end,
    children: [
      Expanded(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const Text(
              "Age",
            ),
            SizedBox(
                height: DeviceSize.isTablet ? 12 : 6),
            TextFormField(
              controller: ageController,
              decoration: InputDecoration(
                border: const OutlineInputBorder(),
                hintText: "Age",
                isDense: true,
                errorText: ageErrorMessage,
              ),
            ),
          ],
        ),
      ),
      const SizedBox(width: 12),
      Expanded(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              "Gender",
              style: textStyle,
            ),
            SizedBox(
                height: DeviceSize.isTablet ? 12 : 6),
            DropdownButtonHideUnderline(
              child: DropdownButtonFormField<String>(
                isExpanded: true,
                decoration: const InputDecoration(
                    border: OutlineInputBorder(),
                    contentPadding: EdgeInsets.symmetric(
                        horizontal: 8.0, vertical: 14.5)),
                hint: Text(
                  'Gender',
                  style: textStyle,
                ),
                value: selectedGender,
                validator: validate,
                borderRadius: BorderRadius.circular(20),
                items: genders.map((String gender) {
                  return DropdownMenuItem<String>(
                    value: gender,
                    child: Text(
                      gender,
                      style: TextStyle(
                          fontSize: 14.0,
                          fontWeight: FontWeight.w400),
                    ),
                  );
                }).toList(),
                onChanged: (String? value) {},
              ),
            ),
          ],
        ),
      )
    ],
  ),
),

我尝试了sizedbox,Container,甚至下拉按钮等等,但没有效果,但它只是破坏了整个程序......

我需要正确且好的方法来对齐所有设备的高度。

flutter
1个回答
0
投票

您可以尝试为 TextField 和 Dropdown 使用固定高度

© www.soinside.com 2019 - 2024. All rights reserved.