fetch json p1
This commit is contained in:
parent
67461e39f5
commit
55d4c2cbed
@ -1,3 +1,5 @@
|
|||||||
|
// import 'dart:ffi';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
@ -146,24 +148,66 @@ class _EmailPageState extends State<EmailPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Future<void> getEmailJson(String threadId) async {
|
||||||
|
// // List< jsonTypeShit = "";
|
||||||
|
// try {
|
||||||
|
// var url = Uri.http(
|
||||||
|
// '127.0.0.1:3001', 'get_thread_messages', {'id': threadId.toString()});
|
||||||
|
// // print(url);
|
||||||
|
// var response = await http.get(url);
|
||||||
|
// // print(response.body);
|
||||||
|
// if (response.statusCode == 200) {
|
||||||
|
// List<dynamic> messagesJson = jsonDecode(response.body);
|
||||||
|
// print(messagesJson);
|
||||||
|
// print("1");
|
||||||
|
// List<SerializableMessage> messages =
|
||||||
|
// messagesJson.map((mj) => SerializableMessage.fromJson(mj)).toList();
|
||||||
|
// // allEmails.addAll(messages);
|
||||||
|
|
||||||
|
// print(messages);
|
||||||
|
// // jsonTypeShit = messages;
|
||||||
|
// } else {
|
||||||
|
// throw Exception(
|
||||||
|
// 'Failed to fetch thread messages for thread ID: $threadId');
|
||||||
|
// }
|
||||||
|
// } catch (e) {
|
||||||
|
// print('Error fetching thread messages: $e');
|
||||||
|
// }
|
||||||
|
// // return(messages)
|
||||||
|
// }
|
||||||
|
|
||||||
Future<String> _getEmailContent(String id) async {
|
Future<String> _getEmailContent(String id) async {
|
||||||
String content = r"""
|
String content = r"""
|
||||||
|
|
||||||
""";
|
""";
|
||||||
|
String restcontent = "";
|
||||||
try {
|
try {
|
||||||
var url = Uri.http('127.0.0.1:3001', 'email', {'id': id});
|
var url = Uri.http('127.0.0.1:3001', 'email', {'id': id});
|
||||||
print(url);
|
// print(url);
|
||||||
var response = await http.get(url);
|
var response = await http.get(url);
|
||||||
print(response.body);
|
// print(response.body);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
print('ok');
|
print('ok');
|
||||||
content = response.body;
|
content = response.body;
|
||||||
|
try {
|
||||||
|
var restUrl =
|
||||||
|
Uri.http('127.0.0.1:3001', 'get_thread_messages', {'id': id});
|
||||||
|
print(restUrl);
|
||||||
|
var restresponse = await http.get(restUrl);
|
||||||
|
print(restresponse.statusCode);
|
||||||
|
if (restresponse.statusCode == 200) {
|
||||||
|
print("ok squared");
|
||||||
|
restcontent = restresponse.body;
|
||||||
|
}
|
||||||
|
} catch (i) {
|
||||||
|
print('jsoncontent caught error: $i');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('_getEmailContent caught error: $e');
|
print('_getEmailContent caught error: $e');
|
||||||
}
|
}
|
||||||
// print(content);
|
// print(content);
|
||||||
|
print(restcontent);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +276,7 @@ class _EmailPageState extends State<EmailPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class EmailListScreen extends StatelessWidget {
|
class EmailListScreen extends StatelessWidget {
|
||||||
List emails;
|
final List emails;
|
||||||
final Future<String> Function(String) getEmailContent;
|
final Future<String> Function(String) getEmailContent;
|
||||||
|
|
||||||
EmailListScreen({required this.emails, required this.getEmailContent});
|
EmailListScreen({required this.emails, required this.getEmailContent});
|
||||||
|
Loading…
Reference in New Issue
Block a user