簡體   English   中英

Google Map 上的 TextFormField?

[英]TextFormField over Google Map?

有什么辦法可以得到這個人:

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

                          ]
                         )
                  )

    ]),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM