我将如何解析嵌套的对象数组,如下所示。
{
"status": "success",
"code": 200,
"message": "The request was successful",
"data": [
{
"name": "Abu Dhabi",
"id": 4139,
"parent": 5153,
"type": "city",
"imageURL": ""
},
{
"name": "Croatia",
"id": 5037,
"parent": 6886,
"type": "country",
"imageURL": ""
},
]
}
Run Code Online (Sandbox Code Playgroud)
我目前正在进行 API 调用,该调用返回的数据格式如上所示。
我的api调用如下:
Future<Location> getLocations() async {
final response =
await http.get('$endpoint/locations', headers: authenticatedHeader);
if (response.statusCode == 200) {
final responseJson = json.decode(response.body);
// If server returns an OK response, parse the JSON.
return Location.fromJson(responseJson);
} else {
// …Run Code Online (Sandbox Code Playgroud) 我有多个图像,每个图像都有自己的重定向链接。目前,这在使用列表视图构建显示手势检测器内的图像时效果很好。
但是,我想添加一个点指示器来显示正在查看的图像。如何获取正在显示的图像的索引?或者在向左或向右滑动时增加/减少计数器。
我已经研究过轮播,但它们似乎不允许每个图像重定向到其他地方。
我目前正在使用 FCM 进行推送通知。当我的应用程序打开时,我会收到通知,但是当应用程序关闭或在后台时 - 在我重新打开应用程序之前我不会收到任何消息。在 XCode 上,我启用了后台提取和远程通知。接下来我应该检查什么?谢谢你。
我在用 firebase_messaging: ^5.1.6
用代码
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print('message is $message');
setState(
() {
showOverlayNotification((context) {
return GestureDetector(
onTap: () {},
child: Platform.isIOS
? MessageNotification(
title: message['notification']['title'],
body: message['notification']['body'],
)
: MessageNotification(
title: message['notification']['title'],
body: message['notification']['body'],
),
);
// }
}, duration: Duration(milliseconds: 4000));
},
);
},
onLaunch: (Map<String, dynamic> message) async {
print('launching');
},
onResume: (Map<String, dynamic> message) async {
print('resuming');
print("onResume: $message");
},
);
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(sound: true, …Run Code Online (Sandbox Code Playgroud) 我希望能够以编程方式更改导航栏选项卡。我在 Page1 中有一个导航到 Page2 的按钮。当我执行此操作时,导航栏消失,因为我没有使用导航栏选择 page2。
我有 4 个 dart 文件,沿着 navigationbar.dart、page1.dart、page2.dart、page3.dart
导航页面是带有孩子的应用程序的主页:
final List<Widget> _children = [
Page1(),
Page2(),
Page3(),
];
return Scaffold(
backgroundColor: Colors.black,
body: _children[_selectedPage],
bottomNavigationBar: _bottomNavigationBar(context),
resizeToAvoidBottomPadding: true,
);
Run Code Online (Sandbox Code Playgroud)