diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 6db35ea..f908d11 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -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', diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index d546050..0c6ff01 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -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', diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 3d75551..6df7c2d 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -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', diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index 692b6fa..fa5b60d 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -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', diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 1c1658e..219d160 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -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', diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 8e2dbb3..cd1b1f7 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -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 diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md index ca8d180..df6ebd3 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-q-r.md @@ -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]', diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index eb55a61..ea3f2ab 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -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]', diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 3bfde7e..1a0fca2 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -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]', diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 4e903d7..4605133 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -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]', diff --git a/lib/src/realtime_message.dart b/lib/src/realtime_message.dart index 66e01c3..1460fe4 100644 --- a/lib/src/realtime_message.dart +++ b/lib/src/realtime_message.dart @@ -2,25 +2,25 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; class RealtimeMessage { - final String event; + final List events; final Map payload; final List 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? events, Map? payload, List? 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 toMap() { return { - 'event': event, + 'events': events, 'payload': payload, 'channels': channels, 'timestamp': timestamp, @@ -38,7 +38,7 @@ class RealtimeMessage { factory RealtimeMessage.fromMap(Map map) { return RealtimeMessage( - event: map['event'], + events: List.from(map['events'] ?? []), payload: Map.from(map['payload'] ?? {}), channels: List.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; diff --git a/pubspec.yaml b/pubspec.yaml index 46633e1..fe070d4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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