我已经为我的应用开发了一个Rest API.它向应用程序发送以下格式的日期2018-09-07T17:29:12+02:00
,我猜+2:00代表我的时区作为一个对象的一部分.
在我的Ffltter应用程序中,一旦我反序列化接收到的对象,它就会将两个小时减go 实际接收到的DateTime对象.
我try 反序列化的类定义如下:
import 'package:json_annotation/json_annotation.dart';
part 'evento.g.dart';
@JsonSerializable(nullable: false)
class Evento {
final int id;
final String nombre;
final String discoteca;
final int precio_desde;
final int edad_minima;
final DateTime fecha_inicio;
final DateTime fecha_fin;
final DateTime fecha_fin_acceso;
final String cartel;
final bool incluyeCopa;
Evento(this.id, this.nombre, this.discoteca, this.precio_desde, this.edad_minima, this.fecha_inicio, this.fecha_fin, this.fecha_fin_acceso, this.cartel, this.incluyeCopa, this.num_tipos);
factory Evento.fromJson(Map<String, dynamic> json) => _$EventoFromJson(json);
Map<String, dynamic> toJson() => _$EventoToJson(this);
}