62 lines
1.6 KiB
Dart
62 lines
1.6 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:just_waveform/just_waveform.dart';
|
|
|
|
import 'radar_attachment.dart';
|
|
|
|
class MessageData {
|
|
final int id;
|
|
final String? text;
|
|
final String? audio;
|
|
final bool writedByAdmin;
|
|
final bool readed;
|
|
final String createdAt;
|
|
final RadarAttachment? radar;
|
|
final File? audioFile;
|
|
final Waveform? waveform;
|
|
|
|
const MessageData({
|
|
required this.id,
|
|
required this.writedByAdmin,
|
|
required this.readed,
|
|
required this.createdAt,
|
|
required this.text,
|
|
required this.audio,
|
|
required this.radar,
|
|
required this.waveform,
|
|
this.audioFile,
|
|
});
|
|
|
|
factory MessageData.fromJson(Map<String, dynamic> json) => MessageData(
|
|
id: json['id'],
|
|
text: json['text'],
|
|
audio: json['audio'],
|
|
writedByAdmin: json['writedByAdmin'],
|
|
readed: json['readed'],
|
|
createdAt: json['createdAt'],
|
|
waveform: json['waveForm'] != null
|
|
? Waveform(
|
|
version: json['version'],
|
|
flags: json['flags'],
|
|
sampleRate: json['sampleRate'],
|
|
samplesPerPixel: json['samplesPerPixel'],
|
|
length: json['length'],
|
|
data: json['data'],
|
|
)
|
|
: null,
|
|
radar: json['radar'] == null
|
|
? null
|
|
: RadarAttachment.fromJson(json['radar'] as Map<String, dynamic>),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'text': text,
|
|
'audio': audio,
|
|
'writedByAdmin': writedByAdmin,
|
|
'readed': readed,
|
|
'createdAt': createdAt,
|
|
'radar': radar?.toJson(),
|
|
};
|
|
}
|