1
import 'package:vkdart/vkontakte.dart';
4
const peerChatIdOffset = 2000000000;
6
/// Transforms a list of attachment objects in the format:
8
/// [{'type': 'photo', 'photo': {...}}, {'type': 'audio', 'audio': {...}}, ...]
10
/// in the attachment model.
11
List<AttachmentModel> transformAttachments(
12
List<Map<String, dynamic>> attachments) =>
14
final attachType = e['type'];
15
return AttachmentModel.fromSpecificModel(e[attachType], attachType);
30
/// Returns the dialog type.
31
/// Accepts the [id] parameter as input,
32
/// if [id] is less than [peerChatIdOffset], [MessageSource.chat] is returned,
33
/// if [id] is less than zero, returned [MessageSource.group],
34
/// in all other cases [MessageSource.user]
35
MessageSource getPeerType(int id) {
36
if (peerChatIdOffset < id) {
37
return MessageSource.chat;
41
return MessageSource.group;
44
return MessageSource.user;
47
/// Checks the [value] for an integer, then checks for one.
48
/// If the value is not an integer, null is returned,
49
bool? checkBoolUtil(Object? value) {