我需要从我的 Flutter 应用程序向 API 发出 GET 请求,该请求需要请求正文为 JSON(原始)。
我在 Postman 中使用 JSON 请求正文测试了 API,它似乎工作正常。
现在在我的 Flutter 应用程序中,我正在尝试做同样的事情:
_fetchDoctorAvailability() async {
var params = {
"doctor_id": "DOC000506",
"date_range": "25/03/2019-25/03/2019" ,
"clinic_id":"LAD000404"
};
Uri uri = Uri.parse("http://theapiiamcalling:8000");
uri.replace(queryParameters: params);
var response = await http.get(uri, headers: {
"Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
HttpHeaders.contentTypeHeader: "application/json",
"callMethod" : "DOCTOR_AVAILABILITY"
});
print('---- status code: ${response.statusCode}');
var jsonData = json.decode(response.body);
print('---- slot: ${jsonData}');
}
Run Code Online (Sandbox Code Playgroud)
但是 API 给了我一个错误说
{message: Missing input json., status: false}
如何在 Flutter 中为 Http GET 请求发送原始(或者更确切地说是 JSON)请求正文?
我有一个名为AddPatientView的页面,其中的BottomNavigationBar包含AddPatientInfo和AddPatientImages页面。这三个都是有状态的小部件。
默认情况下,AddPatientInfo打开,其中包含一堆TextField(用于输入患者信息),用户可以在AddPatientImages页面中添加图像。
问题是如果我在AddPatientInfo上填充TextField,然后转到AddPatientImages,然后返回,则所有TextField都是空的。正确的做法是,由于整个小部件树都得到了重建,因此我丢失了所有填充的数据。
因此,我正在实施,AutomaticKeepAliveClientMixin以便即使更改选项卡也可以保持状态。但这似乎不起作用:
这是我的代码:
AddPatientView(父级)
class AddPatientView extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _AddPatientViewState();
}
}
class _AddPatientViewState extends State<AddPatientView> {
int _currentIndex = 0;
List<Widget> _children;
List<File> _imageFileList = new List<File>();
@override
void initState() {
super.initState();
_children = [
AddPatientInfo(savePatient),
AddPatientImages(_imageFileList)
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("New Patient Record"),
),
body: _children[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
items: [
BottomNavigationBarItem(icon: new Icon(Icons.create), title: new Text('Info')),
BottomNavigationBarItem(icon: …Run Code Online (Sandbox Code Playgroud) 我是Xcode开发的新手.当我第一次打开Xcode 4.2时,我们可以使用Xcode构建不同类型的应用程序(Master Detail,Page Based,Single View,Tabbed,Utility,Empty Application).
我对他们彼此之间的差异感到有些困惑.我做了一些搜索,但到目前为止,我无法理解他们的基本区别.我如何知道选择哪个应用程序来开始开发我自己的应用程序.
如果有人能够以外行的方式向我解释他们的差异和用法.
谢谢.
我正在使用exceljs模块来创建excel文件.问题是它既没有被创建也没有被保存在路径中.
var excel = require('exceljs');
var options = {
filename: './streamed-workbook.xlsx',
useStyles: true,
useSharedStrings: true
};
var workbook = new Excel.stream.xlsx.WorkbookWriter(options);
var sheet = workbook.addWorksheet('My Sheet');
worksheet.columns = [
{ header: 'Id', key: 'id', width: 10 },
{ header: 'Name', key: 'name', width: 32 },
{ header: 'D.O.B.', key: 'DOB', width: 10 }
];
worksheet.addRow({id: 1, name: 'John Doe', dob: new Date(1970,1,1)});
worksheet.addRow({id: 2, name: 'Jane Doe', dob: new Date(1965,1,7)});
worksheet.commit();
workbook.commit().then(function(){
console.log('xls file is written.');
});
Run Code Online (Sandbox Code Playgroud)
但是当我运行代码时没有任何反应.没有创建excel.我在这里错过了什么?
***********************编辑**************************对我的代码进行了以下更改,但仍然无法正常工作.
var …Run Code Online (Sandbox Code Playgroud) 我有一个mySQL数据库,我正在使用phpMyAdmin来访问它.数据库具有表员工,其中包含姓名,地址,电子邮件和密码等字段.
最初密码字段只是VARCHAR (20).但现在我想用SHA-256哈希技术哈希我的密码.
我对数据库没有太多经验,所以我想知道的是 -
我可以在不影响其他字段或整个表的情况下散列所有当前员工的密码吗?
将来当我在数据库中输入数据(来自Web应用程序)时,我在哪里编写散列函数来散列密码?即,是否在前端发生散列,然后散列的密码存储在数据库中,或者密码进入数据库,然后进行散列并存储.
解决方案和建议表示赞赏.
我正在制作Flutter应用程序,并且需要确保用户无法捕获该应用程序的屏幕截图(任何屏幕)。有什么办法可以在Flutter中实现这一目标,还是需要为Android和IOS编写本机代码?
我有一个 FutureBuilder 小部件,它从服务器检索聊天(或更确切地说是更新)并显示它们。这是代码:
Future<List<Chat>> fetchChats(http.Client client, String providerUUID) async {
returns List<Chat>..
}
class ProviderChats extends StatelessWidget {
final List<Chat> chats;
final String providerUUID;
ProviderChats({this.chats, this.providerUUID});
@override
Widget build(BuildContext context) {
return FutureBuilder<List<Chat>>(
future: fetchChats(http.Client(), providerUUID),
builder: (context, snapshot){
if(snapshot.hasError) print(snapshot.error);
return snapshot.hasData ?
ChatsListWidgetClass(chats: snapshot.data) :
Center(child: CircularProgressIndicator());
},
);
}
}
class ChatsListWidgetClass extends StatelessWidget {
final List<Chat> chats;
ChatsListWidgetClass({this.chats});
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: chats.length,
itemBuilder: (context, index) {
return Card(
elevation: 10.0,
child: …Run Code Online (Sandbox Code Playgroud) 我正在使用 Microsoft 的 Graph API 和 Node.js 应用程序创建 Outlook 日历事件。以下文档/示例链接:https://learn.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/calendar-rest-operations#CreateEvents
我的代码:
var options = {
method: 'POST',
url: 'https://graph.microsoft.com/v1.0/me/calendar/events',
headers: {
'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/json'
},
body: {
"subject": "Node.js outlook test",
"body": {
"contentType": "HTML",
"content": "Test event created from node.js"
},
"start": {
"dateTime": "2019-03-25T12:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2019-03-25T14:00:00",
"timeZone": "Pacific Standard Time"
},
"isAllDay": false,
"location": {
"displayName": null
},
"attendees": [{
"emailAddress": {
"address": "my-other-email@gmail.com",
"name": "Adele …Run Code Online (Sandbox Code Playgroud) 我正在从Firebase控制台向我在模拟器上运行的应用发送推送通知消息.
该MyFirebaseMessagingService类看起来是这样的:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = MyFirebaseMessagingService.class.getSimpleName();
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "From: " + remoteMessage.getFrom());
if(remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}
if(remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
Intent intent = new Intent(this, SplashActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "my_channel_01");
notificationBuilder.setContentTitle("FCM Notification");
notificationBuilder.setContentText(remoteMessage.getNotification().getBody());
notificationBuilder.setAutoCancel(true);
notificationBuilder.setSmallIcon(R.mipmap.ic_launcher_round);
notificationBuilder.setContentIntent(pendingIntent);
notificationBuilder.setChannelId("my_channel_01");
NotificationManager …Run Code Online (Sandbox Code Playgroud) 我有一个node.js RESTful API应用程序.没有Web界面(至少截至目前),它只是用作其他服务调用的API端点.
我想在亚马逊的AWS云上托管它.我在两个选项之间感到困惑
要么
或者我可以在EC2上运行我的代码并使用API网关吗?
当涉及到node.js RESTful api应用程序时,我对EC2和API网关的不同之处感到困惑
amazon-ec2 amazon-web-services node.js aws-lambda aws-api-gateway