1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import 'dart:async';
import 'dart:collection';
import 'package:connectycube_sdk/connectycube_sdk.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:universal_io/io.dart';
import 'platform_utils.dart';
void showDialogError(exception, context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Error"),
content: Text("Something went wrong $exception"),
actions: <Widget>[
TextButton(
child: const Text("OK"),
onPressed: () => Navigator.of(context).pop(),
)
],
);
});
}
void showDialogMsg(msg, context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Alert"),
content: Text(msg),
actions: <Widget>[
TextButton(
child: const Text("OK"),
onPressed: () => Navigator.of(context).pop(),
)
],
);
});
}
class ListItem<T> {
bool isSelected = false; //Selection property to highlight or not
T data; //Data of the user
ListItem(this.data); //Constructor to assign the data
}
Future<Map<int, CubeUser>> getUsersByIds(Set<int> ids) async {
Completer<Map<int, CubeUser>> completer = Completer();
Map<int, CubeUser> users = HashMap();
try {
var result = await (getAllUsersByIds(ids)
as FutureOr<PagedResult<CubeUser>>);
users.addAll(Map.fromIterable(result.items,
key: (item) => item.id, value: (item) => item));
} catch (ex) {
log("exception= $ex");
}
completer.complete(users);
return completer.future;
}
Future<CubeFile> getUploadingImageFuture(FilePickerResult result) async {
if(kIsWeb){
return uploadRawFile(result.files.single.bytes!, result.files.single.name, isPublic: true, onProgress: (progress) {
log("uploadImageFile progress= $progress");
});
} else {
return uploadFile(File(result.files.single.path!), isPublic: true, onProgress: (progress) {
log("uploadImageFile progress= $progress");
});
}
}
refreshBadgeCount(){
getUnreadMessagesCount().then((result) {
updateBadgeCount(result['total']);
});
}