From 3c78f11f2cbe051df303b0d8f8cc765d038773d2 Mon Sep 17 00:00:00 2001 From: Lukas Lihotzki Date: Mon, 24 Feb 2020 17:54:43 +0100 Subject: [PATCH] [MatrixFile] Use Uint8List instead of List --- lib/src/utils/matrix_file.dart | 5 ++++- test/client_test.dart | 3 ++- test/room_test.dart | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/src/utils/matrix_file.dart b/lib/src/utils/matrix_file.dart index 3d024d8..91268c6 100644 --- a/lib/src/utils/matrix_file.dart +++ b/lib/src/utils/matrix_file.dart @@ -1,6 +1,9 @@ /// Workaround until [File] in dart:io and dart:html is unified + +import 'dart:typed_data'; + class MatrixFile { - List bytes; + Uint8List bytes; String path; MatrixFile({this.bytes, String path}) : this.path = path.toLowerCase(); diff --git a/test/client_test.dart b/test/client_test.dart index 14c5cca..7f81e0c 100644 --- a/test/client_test.dart +++ b/test/client_test.dart @@ -23,6 +23,7 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:typed_data'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/src/account_data.dart'; @@ -433,7 +434,7 @@ void main() { test('setAvatar', () async { final MatrixFile testFile = - MatrixFile(bytes: [], path: "fake/path/file.jpeg"); + MatrixFile(bytes: Uint8List(0), path: "fake/path/file.jpeg"); await matrix.setAvatar(testFile); }); diff --git a/test/room_test.dart b/test/room_test.dart index cd9d7b9..822b2f9 100644 --- a/test/room_test.dart +++ b/test/room_test.dart @@ -31,6 +31,8 @@ import 'package:test/test.dart'; import 'fake_matrix_api.dart'; +import 'dart:typed_data'; + void main() { Client matrix; Room room; @@ -322,7 +324,7 @@ void main() { test('setAvatar', () async { final MatrixFile testFile = - MatrixFile(bytes: [], path: "fake/path/file.jpeg"); + MatrixFile(bytes: Uint8List(0), path: "fake/path/file.jpeg"); final dynamic resp = await room.setAvatar(testFile); expect(resp, "YUwRidLecu:example.com"); }); @@ -350,7 +352,7 @@ void main() { test('sendFileEvent', () async { final MatrixFile testFile = - MatrixFile(bytes: [], path: "fake/path/file.jpeg"); + MatrixFile(bytes: Uint8List(0), path: "fake/path/file.jpeg"); final dynamic resp = await room.sendFileEvent(testFile, msgType: "m.file", txid: "testtxid"); expect(resp, "42");