Flutter 颤振中的卷曲问题

Flutter 颤振中的卷曲问题,flutter,Flutter,我一直在尝试将PVOutputs API CURL命令放入我的开发中,但它们似乎无法做到这一点 CURL命令是:CURL-H“X-Pvoutput-Apikey:Your-API-Key”-H“X-Pvoutput-SystemId:Your-System-Id”https://pvoutput.org/service/r2/getoutput.jsp 下面是我如何使用http请求尝试的: import 'dart:convert'; import 'package:flutter/cuper

我一直在尝试将PVOutputs API CURL命令放入我的开发中,但它们似乎无法做到这一点

CURL命令是:
CURL-H“X-Pvoutput-Apikey:Your-API-Key”-H“X-Pvoutput-SystemId:Your-System-Id”https://pvoutput.org/service/r2/getoutput.jsp

下面是我如何使用http请求尝试的:

import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'package:http/http.dart' as http;

void main() {
  runApp(new MaterialApp(home: new MyApp()));
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'SolarGridx',
      theme: ThemeData(primaryColor: Colors.white),
      home: CurlScreen(),
    );
  }
}

var responseJson;

class CurlScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(body: Center(child: Text(responseJson)));
  }
}

Future<void> EnergyInfo() async {
  String url = 'https://pvoutput.org/service/r2/getoutput.jsp';
  Map<String, String> headers = {
    "Content-Type": "application/json",
    "X-Pvoutput-Apikey": "064154d4ee89b29f195179ff5fbd30c908fddf45",
    "X-Pvoutput-SystemId": "77117",
  };
  var response = await http.post(url, headers: headers);

  int statusCode = response.statusCode;
  print('This is the statuscode: $statusCode');
  final responseJson = json.decode(response.body);
  print(responseJson);

  print('This is the API response: $responseJson');
}
导入'dart:convert';
进口“包装:颤振/cupertino.dart”;
进口“包装:颤振/材料.省道”;
将“package:http/http.dart”导入为http;
void main(){
runApp(newmaterialapp)(主页:newmyapp());
}
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:“SolarGridx”,
主题:主题数据(原色:Colors.white),
主页:CurlScreen(),
);
}
}
var responseJson;
类CurlScreen扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回脚手架(主体:中心(子:文本(响应));
}
}
Future EnergyInfo()异步{
字符串url='0https://pvoutput.org/service/r2/getoutput.jsp';
映射头={
“内容类型”:“应用程序/json”,
“X-Pvoutput-Apikey”:“064154d4ee89b29f195179ff5fbd30c908fddf45”,
“X-Pvoutput-SystemId”:“77117”,
};
var response=wait http.post(url,headers:headers);
int statusCode=response.statusCode;
打印('这是状态代码:$statuscode');
final responseJson=json.decode(response.body);
印刷品(responseJson);
打印(“这是API响应:$responseJson”);
}

我也尝试过使用CURL依赖项,但也不起作用。

您的颤振代码似乎没有问题您的颤振代码似乎没有问题