我试图对我的类进行编码,以便将一个put http发送到firebase,但是当我打印User.toMap时,我的函数显示了一个带有"Instance of 'Address'“的列表。 {id: -LVsaRJKo3vo6q9NWZn_, name: User 38197, email: null, address: [Instance of 'Address']} class User {
String id;
String name;
String email;
List<Address> address = new
我试图用POST http请求将一个包含三个参数的列表发送到服务器。响应状态为200,但是当我打印响应体时,响应体为null,并且它一直在循环中打印它。我不知道我做错了什么。任何帮助都将不胜感激!
员额请求
static Future<Athlete> insertPresences(
int athleteId, int departmentId, int teamId) async {
var body = [
{"athleteId": athleteId, "departmentId": department
Main.dart
import 'package:flutter/material.dart';
import 'package:flutter_application_1/currentWeather.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context)
我正在尝试解析JSON并将其转换为列表视图。
我正在获取响应体,它也被转换为列表,但它将null发送到未来的构建器,我得到了这个错误:
/flutter ( 9715): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 9715): The following assertion was thrown building FutureBuilder<List<Event>>(dirty, stat
更新:感谢@Rjulcaa answer,我的地图现在是一个列表,但是这个列表没有显示在UI上。我发现我需要用一个FutureBuilder来处理未来,所以如果有人遇到这个问题,记得在UI的主体中添加一个FutureBuilder,并在构建器上返回您想要显示的小部件。 我正在制作一个待办事项列表教程,我试图在我的todoList上添加编码功能,并将其保存在sharedPreferences上,当我启动应用程序时,它会在屏幕上检索到它 这是我的TODO类 class Todo {
Todo ({this.title,this.isDone = false});
String title;
b
我所使用的模型:
class ExerciseSession{
final String Id;
final String cw_id;
final String client_id;
final String date;
final int challenge_rating;
final String apiCode;
final String userId;
ExerciseSession({this.Id, this.cw_id, this.client_id, this.date
下面的示例在我的列表视图中加载数据,但是有些字符是无效的。我试着用utf8
var jsonData = json.decode(response.body);
var jsonData = utf8.decode(response.bodyBytes);
使用utf8时,结果是正确的,但在listTile中加载数据时会得到引号和错误。
//I/flutter ( 4629): {"items":[{"name":"xyšć", //character is OK but get quotation mark
//I/flutter ( 46
我在将响应json放在列表上时遇到了问题。 当我尝试转换主体数据(数据来自的地方)时,我得到了错误: The getter 'body' isn't defined for the type 'Response<dynamic>'.
Try importing the library that defines 'body', correcting the name to the name of an existing getter, or defining a getter or field named 'body&
我有一个函数postList,它从Wordpress生成的json中检索帖子列表。id变量是页码,所以每次我到达底部,它都会添加一个循环进度条,并以卡片的形式加载更多的值(customCard函数)。
_getJsonData(url, page) async {
final response = await http.get("$url?page=$page");
if (response.statusCode == 200) {
// If the call to the server was successful, parse the JSON
r
我正在尝试将json对象发送到api端点。但我得到了以下信息: I / flutter(28184): 200
I / flutter(28184): {"error": "the JSON object must be str, not 'bytes'"} 我尝试过以下几种方法: Future<http.Response> sendPost() async{
var post = {
"profile_id" : "${_profile_id}",
"prof
我正在尝试通过REST API使用flutter将List传递给我的服务器。
下面是代码
Future<void> saveOrderItemList(List<OrderItem> orderItems) async {
int responsetag = 0;
try {
await http.post("http://url to post the data",
body: convert.json.encode(orderItems.toJson()), //This line do not wo