【发布时间】:2021-06-05 14:23:10
【问题描述】:
我有一行带有一个文本字段和一个浮动操作按钮。每次我按下浮动操作按钮时,文本字段都会被激活并且键盘会出现。我怎样才能防止这种行为? 浮动操作按钮触发在地图上显示设备位置,如果您不允许位置服务或想要在其他地方搜索,则文本字段用于位置搜索。
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),
),
),
),
],
),
),
),
],
),
);
【问题讨论】:
标签: flutter keyboard floating-action-button