fix: realtime event payload

This commit is contained in:
Torsten Dittmann
2022-05-17 14:15:08 +02:00
parent 653b728a9d
commit bdb4ba6d27
12 changed files with 112 additions and 20 deletions
+10 -1
View File
@@ -8,9 +8,18 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = avatars.getBrowser(
code: 'aa',
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: avatars.getBrowser(
code: 'aa',
+10 -1
View File
@@ -8,9 +8,18 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = avatars.getCreditCard(
code: 'amex',
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: avatars.getCreditCard(
code: 'amex',
+10 -1
View File
@@ -8,9 +8,18 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = avatars.getFavicon(
url: 'https://example.com',
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: avatars.getFavicon(
url: 'https://example.com',
+10 -1
View File
@@ -8,9 +8,18 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = avatars.getFlag(
code: 'af',
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: avatars.getFlag(
code: 'af',
+10 -1
View File
@@ -8,9 +8,18 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = avatars.getImage(
url: 'https://example.com',
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: avatars.getImage(
url: 'https://example.com',
+9 -1
View File
@@ -8,9 +8,17 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = avatars.getInitials(
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: avatars.getInitials(
), //works for both public file and private file, for private files you need to be logged in
+10 -1
View File
@@ -8,9 +8,18 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = avatars.getQR(
text: '[TEXT]',
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: avatars.getQR(
text: '[TEXT]',
+11 -1
View File
@@ -8,9 +8,19 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = storage.getFileDownload(
bucketId: '[BUCKET_ID]',
fileId: '[FILE_ID]',
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: storage.getFileDownload(
bucketId: '[BUCKET_ID]',
+11 -1
View File
@@ -8,9 +8,19 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = storage.getFilePreview(
bucketId: '[BUCKET_ID]',
fileId: '[FILE_ID]',
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: storage.getFilePreview(
bucketId: '[BUCKET_ID]',
+11 -1
View File
@@ -8,9 +8,19 @@ void main() { // Init SDK
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
// downloading file
Future result = storage.getFileView(
bucketId: '[BUCKET_ID]',
fileId: '[FILE_ID]',
).then((bytes) {
final file = File('path_to_file/filename.ext');
file.writeAsBytesSync(bytes)
}).catchError((error) {
print(error.response);
})
}
//displaying image
//displaying image preview
FutureBuilder(
future: storage.getFileView(
bucketId: '[BUCKET_ID]',
+9 -9
View File
@@ -2,25 +2,25 @@ import 'dart:convert';
import 'package:flutter/foundation.dart';
class RealtimeMessage {
final String event;
final List<String> events;
final Map<String, dynamic> payload;
final List<String> channels;
final int timestamp;
RealtimeMessage({
required this.event,
required this.events,
required this.payload,
required this.channels,
required this.timestamp,
});
RealtimeMessage copyWith({
String? event,
List<String>? events,
Map<String, dynamic>? payload,
List<String>? channels,
int? timestamp,
}) {
return RealtimeMessage(
event: event ?? this.event,
events: events ?? this.events,
payload: payload ?? this.payload,
channels: channels ?? this.channels,
timestamp: timestamp ?? this.timestamp,
@@ -29,7 +29,7 @@ class RealtimeMessage {
Map<String, dynamic> toMap() {
return {
'event': event,
'events': events,
'payload': payload,
'channels': channels,
'timestamp': timestamp,
@@ -38,7 +38,7 @@ class RealtimeMessage {
factory RealtimeMessage.fromMap(Map<String, dynamic> map) {
return RealtimeMessage(
event: map['event'],
events: List<String>.from(map['events'] ?? []),
payload: Map<String, dynamic>.from(map['payload'] ?? <String, dynamic>{}),
channels: List<String>.from(map['channels'] ?? []),
timestamp: map['timestamp'],
@@ -52,7 +52,7 @@ class RealtimeMessage {
@override
String toString() {
return 'RealtimeMessage(event: $event, payload: $payload, channels: $channels, timestamp: $timestamp)';
return 'RealtimeMessage(events: $events, payload: $payload, channels: $channels, timestamp: $timestamp)';
}
@override
@@ -60,7 +60,7 @@ class RealtimeMessage {
if (identical(this, other)) return true;
return other is RealtimeMessage &&
other.event == event &&
listEquals(other.events, events) &&
mapEquals(other.payload, payload) &&
listEquals(other.channels, channels) &&
other.timestamp == timestamp;
@@ -68,7 +68,7 @@ class RealtimeMessage {
@override
int get hashCode {
return event.hashCode ^
return events.hashCode ^
payload.hashCode ^
channels.hashCode ^
timestamp.hashCode;
+1 -1
View File
@@ -16,7 +16,7 @@ dependencies:
http: ^0.13.4
package_info_plus: 1.4.2
path_provider: ^2.0.9
web_socket_channel: ^2.1.0
web_socket_channel: ^2.2.0
dev_dependencies:
flutter_lints: ^1.0.4