提问者:小点点

谷歌地图上的TextFormField?


有没有办法让这家伙:

                TextFormField(
                  controller: feedbackController,
                  cursorColor: Colors.white,
                  style: TextStyle(
                    color: Colors.white,
                  ),
                  decoration: InputDecoration(labelText: 'text input'),

显示在下面地图的顶部?

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位于地图的顶部或底部。 有什么想法吗?


共1个答案

匿名用户

TextFormField没有self大小,它从其父级获取大小,所以我想这就是您的问题。 尝试将textfield包装在已调整大小的框或已调整大小的容器中,然后放入堆栈:

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'),
 
                        )

                          ]
                         )
                  )

    ]),