android - 是否在Google Map上使用TextFormField?

标签 android flutter dart

有什么办法可以让这个家伙:

                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/

相关文章:

android - 互联网连接检查在 android 中失败

java - 无法创建与数据库服务器的连接 - Eclipse MySQL 错误

Flutter:更改下拉菜单项选择列表的背景颜色

flutter:如何向底部导航栏项目添加填充,使项目彼此保持更远的距离

user-interface - 按一个因子调整动态大小的 Widget

flutter - 在 flutter 中更改包名称后 app-release.apk 未安装?

android - 不支持 React-native Animation.event 样式属性

java - 数字日期格式

android - MultiProvider 必须指定一个子 'package:provider/src/inherited_provider.dart' : Failed assertion: 'builder != null || child != null'

flutter - 如何创建一个 BlocListener 来监听 flutter 中的所有页面并访问 MaterialApp 上下文?