SDK更新后可序列化对象损坏

时间:2018-08-30 12:48:10

标签: serialization dart flutter mixins

一个月前,我跟随this tutorial讨论了有关序列化的问题,一切顺利。 但是,昨天我更新了flutter SDK的安装,并且代码被破坏了。

import 'package:json_annotation/json_annotation.dart';

part 'evento.g.dart';

@JsonSerializable()
class Evento extends Object with _$EventoSerializerMixin {
  final int id;
    final String nombre;
    final String discoteca;
    final int precio;
    final int edad;
    final DateTime fecha;
    final String cartel;
  final bool incluyeCopa;
  final bool esNominal;
  final bool permitePagoTaquilla;
    Evento(this.id, this.nombre, this.discoteca, this.precio, this.edad, this.fecha, this.cartel, this.incluyeCopa, this.esNominal, this.permitePagoTaquilla);
  factory Evento.fromJson(Map<String, dynamic> json) => _$EventoFromJson(json);
}

运行flutter packages pub run build_runner build命令后,代码中的所有错误都消失了(如本教程中所述),但是我的IDE一直在说_$EventoSerializerMixin,其中[dart] Classes can only mixin other classes.和{{1} }。文件[dart] Undefined class '_$EventoSerializerMixin'.已按预期正确创建:

evento.g.dart

我该如何解决?

0 个答案:

没有答案