0

我正在做一个项目,当我按下一个显示在 textFormField 旁边的按钮时,该项目必须显示药物列表。但是应用程序的发布版本和正在开发的应用程序有点不同。在生产版本中,它始终显示图标。但是在发布版本中,当我将项目添加到列表时它会消失。在发布版本中,列表占据了屏幕的整个宽度。但是当我开发时,它并​​没有占据整个屏幕的宽度。

这是我用来创建 TextFormField 和 DropDownButton 的代码。

Padding(
  padding: EdgeInsets.symmetric(horizontal: 12, vertical: 10),
  child: (SizedBox(
    width: MediaQuery.of(context).size.width,
    child: Stack(children: [
      Align(
          alignment: Alignment.centerRight,
          child: DropdownButton<String>(
              elevation: 16,
              icon: Icon(Icons.arrow_drop_down),
              underline: Container(
                color: Colors.transparent,
                height: 2,
              ),
              onChanged: (newValue) {},
              items: List<String>.from(starInvestigations)
                  .map<DropdownMenuItem<String>>((String value) {
                return DropdownMenuItem<String>(
                    value: value,
                    child: Container(
                        color: Colors.transparent,
                        width: double.infinity,
                        child: TextButton(
                          child: Align(
                              alignment: Alignment.centerLeft,
                              child: Text(value,
                                  textAlign: TextAlign.left)),
                          onPressed: () {
                            setState(() {
                              controllerInvestigation.text = value;
                            });
                          },
                        )));
              }).toList())),
      SizedBox(
        width: MediaQuery.of(context).size.width - 50,
        child: TextFieldSearch(
            controller: controllerInvestigation,
            initialList: allInvestigations,
            label: "Enter the Investigation",
            decoration: InputDecoration(
              focusColor: Colors.purple,
              border: OutlineInputBorder(),
              labelText: "Enter the Investigation",
              icon: FaIcon(FontAwesomeIcons.vials),
            )),
      ),
    ])))),

这是模拟器中正在开发的应用程序的图像

这是发布版本的图像

4

0 回答 0