Map<String, dynamic> toJson() { return <String, dynamic>{ 'type': type.index, 'duration': duration }; }