按下浮动操作按钮时防止键盘出现

Prevent keyboard coming up when floating action button is pressed

我有一行包含文本字段和浮动操作按钮。每次我按下浮动操作按钮时,文本字段都会被激活,键盘也会出现。我怎样才能防止这种行为? 浮动操作按钮触发在地图上显示设备位置,如果您不允许位置服务或想在其他地方搜索,则文本字段用于位置搜索。

Container(
                padding: const EdgeInsets.only(left: 10, right: 10),
                color: Colors.white,
// Text field for search
                child: Row(
                  children: [
                    TextField(
                      style: GoogleFonts.juliusSansOne(
                          fontSize: 14, color: Colors.black),
                      controller: controllerTXT,
// new camera position depending on user input
                      onSubmitted: (inputText) async {
                        LatLng? searchPosition = await getLocationLine();
                        if (searchPosition != null) {
                          searchInputPosition(CameraPosition(
                            target: searchPosition,
                            zoom: 9.151926040649414,
                          ));
                          setState(() {
                            position = searchPosition;
                          });
                        }
                      },
                      textInputAction: TextInputAction.go,
                      decoration: InputDecoration(
                        filled: true,
                        fillColor: Colors.white,
                        hintText: "PLZ/Ort",
                        border: InputBorder.none,
                        contentPadding: EdgeInsets.only(left: 20.0, top: 16.0),
                        icon: Container(
                          width: 10,
                          height: 30,
                          child: Icon(
                            Icons.search,
                            color: Colors.black,
                            size: 36,
                          ),
                        ),
                      ),
                    ),
                    SizedBox(
                      width: 16,
                    ),
                    Padding(
                      padding: const EdgeInsets.fromLTRB(
                        8.0,
                        8.0,
                        0,
                        8.0,
                      ),
                      child: SizedBox(
                        width: 30,
                        height: 30,
// my Location Button
                        child: FloatingActionButton(
                          onPressed: _myPosition,
                          materialTapTargetSize: MaterialTapTargetSize.padded,
                          backgroundColor: Color.fromRGBO(180, 24, 32, 1),
                          child: Icon(Icons.my_location_rounded, size: 28.0),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      );

我找到了解决方案,这是我的愚蠢错误: 我在 MediaQuery 的 if/else 中有相同的代码,但忘记更新它。在这个 else 树中,floatingActionButton 被声明为 suffixIcon 而不是行的一部分。