structs.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import 'package:flutter/material.dart';
  2. import 'package:http/http.dart' as http;
  3. import 'dart:convert';
  4. import 'dart:ui_web' as ui;
  5. import 'dart:html' as html;
  6. import 'augment.dart';
  7. import 'dart:js' as js;
  8. import 'api_service.dart';
  9. import 'dart:convert'; // For JSON decoding
  10. import 'package:intl/intl.dart';
  11. class GetThreadResponse {
  12. final int id;
  13. final List<String> messages;
  14. final String subject;
  15. final DateTime date;
  16. final String from_name;
  17. final String from_address;
  18. final List<MailAddress> to;
  19. GetThreadResponse({
  20. required this.id,
  21. required this.messages,
  22. required this.subject,
  23. required this.date,
  24. required this.from_name,
  25. required this.from_address,
  26. required this.to,
  27. });
  28. factory GetThreadResponse.fromJson(Map<String, dynamic> json) {
  29. var messagesList = json['messages'] as List<dynamic>;
  30. var toList = json['to'] as List<dynamic>;
  31. // var ccList = json['cc'] as List;
  32. return GetThreadResponse (
  33. id: json['id'],
  34. // messages: messagesList.map((message) => message.toString()).toList(),
  35. messages: List<String>.from(json['messages']),
  36. subject: json['subject'],
  37. date: DateTime.parse(json['date']),
  38. from_name: json['from_name'],
  39. from_address: json['from_address'],
  40. to: toList.map((i)=> MailAddress.fromJson(i)).toList(),
  41. );
  42. }
  43. }