有什么办法可以让这个家伙:
TextFormField(
controller: feedbackController,
cursorColor: Colors.white,
style: TextStyle(
color: Colors.white,
),
decoration: InputDecoration(labelText: 'text input'),
显示在下面的 map 顶部?Stack(
children: <Widget>[
Container(
child: GoogleMap(
markers: Set<Marker>.of(markers.values),
initialCameraPosition: CameraPosition(
target: LatLng(lat, lng),
zoom: 9.0),
myLocationEnabled: true,
compassEnabled: true,
myLocationButtonEnabled: true,
mapType: MapType.normal,
onMapCreated: (GoogleMapController controller) {
controller.setMapStyle(Utils.mapStyles);
}),
),
Stack(
children: <Widget>[
Positioned(
bottom: 0,
right: 250,
child: RaisedButton(
onPressed: _dosomething ,
child: Text("dosomething"),
color: Colors.grey,
textColor: Colors.black,)),
]),
值得庆幸的是,凸起的按钮显示得很好...我希望TextFormField位于 map 的顶部或底部。有任何想法吗?
最佳答案
TextFormField没有自身大小,它从其父级获取大小,所以我想这是您的问题。尝试将文本字段包装在大小合适的盒子或大小合适的容器中,然后放入堆栈中:
Stack(
children: <Widget>[
Container(
child: GoogleMap(
markers: Set<Marker>.of(markers.values),
initialCameraPosition: CameraPosition(
target: LatLng(lat, lng),
zoom: 9.0),
myLocationEnabled: true,
compassEnabled: true,
myLocationButtonEnabled: true,
mapType: MapType.normal,
onMapCreated: (GoogleMapController controller) {
controller.setMapStyle(Utils.mapStyles);
}),
),
Stack(
children: <Widget>[
Positioned(
bottom: 0,
right: 250,
child: RaisedButton(
onPressed: _dosomething ,
child: Text("dosomething"),
color: Colors.grey,
textColor: Colors.black,)),
]),
Container(
height: MediaQuery.of(context).size.width * 0.3,
width: MediaQuery.of(context).size.width * 0.8,
child: Row(
children: <Widget> [
Expanded(
child: TextFormField(
controller: feedbackController,
cursorColor: Colors.white,
style: TextStyle(
color: Colors.white,
),
decoration: InputDecoration(labelText: 'text input'),
)
]
)
)
]),
关于android - 是否在Google Map上使用TextFormField?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63193164/