【发布时间】:2020-06-26 22:25:00
【问题描述】:
我正在尝试使用 Google 地图构建一个带有颤振的 IOS 应用程序。但是,当我点击搜索框并打开键盘搜索应用程序冻结的地方时,我什至无法输入。这是在模拟器中,因为我没有物理 iPhone 来测试它。我是一个颤抖的初学者,不知道出了什么问题(怀疑我搞砸了)。我对此进行了研究,发现以前版本的颤振存在 IOS 键盘滞后的问题,但没有提到应用程序被完全冻结。我对Changed 进行了评论,认为它与冻结有关。
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
Completer<GoogleMapController> _controller = Completer();
static const LatLng _center = const LatLng(45.521563, -122.677433);
String searchValue = "";
String _mapStyle;
@override
void initState() {
super.initState();
rootBundle.loadString('assets/map_style.txt').then((string) {
_mapStyle = string;
});
}
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
backgroundColor: GlobalAppConstants.appMainColor,
),
child: GestureDetector(
onTap:() {
FocusScope.of(context).requestFocus(new FocusNode());
},
child: Stack(
children: <Widget>[
Container(
child: GoogleMap(
initialCameraPosition:
CameraPosition(target: _center, zoom: 1.0),
mapType: MapType.normal,
onMapCreated: (GoogleMapController controller) {
controller.setMapStyle(_mapStyle);
_controller.complete(controller);
},
),
),
Container(
color: Color.fromRGBO(255, 255, 255, 0.7),
),
Align(
alignment: Alignment(0.0, -0.5),
child: Column(
children: <Widget>[
Text(
'My Text',
style:
TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
Container(
padding: EdgeInsetsDirectional.only(top: 20.0),
),
Text(
'Search Country',
style: TextStyle(
color: GlobalAppConstants.appMainColor,
fontWeight: FontWeight.bold),
),
Container(
width: 140.0,
padding: EdgeInsetsDirectional.only(top: 0.0),
child: Divider(
thickness: 7.0,
color: GlobalAppConstants.appMainColor,
),
),
Container(
padding: EdgeInsetsDirectional.only(
start: 10.0, end: 10.0, top: 10.0),
height: 50,
child: CupertinoTextField(
placeholder: 'Search Country',
padding: EdgeInsets.symmetric(
horizontal: 10.0, vertical: 0.4),
prefix: Container(
padding: EdgeInsetsDirectional.only(start: 10.0),
child: Icon(
CupertinoIcons.search,
color: CupertinoColors.black,
size: 22.0,
),
),
decoration: BoxDecoration(
color: CupertinoColors.white,
boxShadow: [
BoxShadow(
color: CupertinoColors.black,
)
],
),
// onChanged: (String value) {
//// setState(() {
//// searchValue = value;
//// });
// },
),
)
],
),
)
],
),
));
}
}
我确实添加了<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
到我的 Info.plist 文件。这似乎是我发现的论坛中的讨论。任何帮助,将不胜感激。谢谢。
【问题讨论】:
标签: ios google-maps flutter mobile-development